|
| 1 | +Login to the telementry database as a user with query permisions |
| 2 | +To get the exposed packages execute |
| 3 | + |
| 4 | +desc DBMS_ADB_TELEMETRY_QUERY |
| 5 | + |
| 6 | +Note that all of the following REQUIRE absolute timestamps Unix Epoch offsets to get that look at https://www.epochconverter.com/ (or risk chatGPT) |
| 7 | + |
| 8 | +this should get the most recent value before the provided timestamp (within 5 mins) for the current charge percentage |
| 9 | +Note The OTEL Naming documents say the use of . as a grouping separator is OK (as long as there are not two concurrent dots - so no ..) |
| 10 | +it does however recomend against the use of upper case (it says should, not must though) and recommends the use of snake case - so the |
| 11 | +metric name would be iot.normalized.current_charge_percentage and the code automaticallu converts any names (attribute key, metric |
| 12 | +name, attribute name, event name) into dot separated snake_case so |
| 13 | +IN theory a promql would be something like this |
| 14 | +select dbms_ADB_telemetry_query.PROMQL_INSTANT('iot.normalized.current_charge_percentage', 1782926574) from dual |
| 15 | +HOWEVER |
| 16 | +currently there seems to be a bug in the promql parsing code that can't handle the simple from using dot |
| 17 | +separation, so for now we need to do something like |
| 18 | +select dbms_cloud_telemetry_query.promql_instant('{__name__="iot.normalized.current_charge_percentage"}',1782928327) from dual; |
| 19 | + |
| 20 | +ADDITIONALLY |
| 21 | +is restricting based on tags there is an additional problem (probabaly a bug to be honest) in that the names (key) of the attributes |
| 22 | +have any . in the name replaced with _, so iot.digital_twin.model_name becoms a tag of iot_digital_twin_model_name which rather messes |
| 23 | +up the naming hierarchy. Engineering are currently looking to see if this is a ingest "undocumented feature" or a deliberate choice, but |
| 24 | +it's clear from the OTLP naming rules ( https://opentelemetry.io/docs/specs/semconv/general/naming/ ) that . is allowed as a namespace separator |
| 25 | + |
| 26 | +Thge PROMSQL procedures and their arguments are below, note that you can name a param using name -> value, or use positional params |
| 27 | +based on the order below, all CLOB's are JSOB formatted prometheus structures. |
| 28 | +The promql is defined at https://prometheus.io/docs/prometheus/latest/querying/basics/ |
| 29 | + |
| 30 | + |
| 31 | +FUNCTION PROMQL_INSTANT RETURNS CLOB |
| 32 | +the last value of the metric BEFORE or at the time stamp (with a max of 300 seconds prior) |
| 33 | + |
| 34 | + Argument Name Type In/Out Default? |
| 35 | + ------------------------- -------------------- ------ -------- |
| 36 | + PROMQL_QUERY VARCHAR2 IN |
| 37 | + INSTANT_TIME_EPOCH NUMBER IN |
| 38 | + FETCH_SQL NUMBER IN Y |
| 39 | + |
| 40 | +FUNCTION PROMQL_LABEL RETURNS CLOB |
| 41 | +Get the labels (need more info on this) |
| 42 | + |
| 43 | + Argument Name Type In/Out Default? |
| 44 | + ------------------------- -------------------- ------ -------- |
| 45 | + PROMQL_QUERY VARCHAR2 IN |
| 46 | + START_TIME_EPOCH NUMBER IN |
| 47 | + END_TIME_EPOCH NUMBER IN |
| 48 | + FETCH_SQL NUMBER IN Y |
| 49 | + |
| 50 | +FUNCTION PROMQL_RANGE RETURNS CLOB |
| 51 | +The values in the given range |
| 52 | +STEP_SIZE_SECONDS sets the size of the step, which returns a value for each step (like |
| 53 | +the instant) between the start and end time (defaults to 10 seconds). This is basically |
| 54 | +the PROMQL_INSTANT run once for each step. |
| 55 | + |
| 56 | + Argument Name Type In/Out Default? |
| 57 | + ------------------------- -------------------- ------ -------- |
| 58 | + PROMQL_QUERY VARCHAR2 IN |
| 59 | + START_TIME_EPOCH NUMBER IN |
| 60 | + END_TIME_EPOCH NUMBER IN |
| 61 | + STEP_SIZE_SECONDS NUMBER IN |
| 62 | + FETCH_SQL NUMBER IN Y |
| 63 | + |
| 64 | +FUNCTION PROMQL_SERIES RETURNS CLOB |
| 65 | +Get the labels (need more info on this) |
| 66 | + Argument Name Type In/Out Default? |
| 67 | + ------------------------- -------------------- ------ -------- |
| 68 | + PROMQL_QUERY VARCHAR2 IN |
| 69 | + START_TIME_EPOCH NUMBER IN |
| 70 | + END_TIME_EPOCH NUMBER IN |
| 71 | + FETCH_SQL NUMBER IN Y |
| 72 | + |
| 73 | +example (using the current limitations on naming) |
| 74 | +select dbms_cloud_telemetry_query.promql_instant('{__name__="iot.normalized.inverter_power_watts_point_in_time"}',1782928327) from dual; |
| 75 | + |
| 76 | +getting a set of ranges using the default step of 10 |
| 77 | +select dbms_cloud_telemetry_query.promql_range('{__name__="iot.normalized.InverterPowerWattsPointInTime"}',1782925327, 1782928327) from dual; |
| 78 | + |
| 79 | +getting a set of ranged using a step of 100 |
0 commit comments