prometheus_oracle_exporter icon indicating copy to clipboard operation
prometheus_oracle_exporter copied to clipboard

Labels are missing in metrics

Open ChSanjayBabu opened this issue 4 years ago • 3 comments

Hi,

labels in custom query are not functioning properly, Lets take the example given in Installation part

queries:
 - sql: "select 1 as column1, 2 as column2, 3 as label_column from dual"
   name: sample1
   help: "This is my metric number 1"
   metrics:
    - column1
    - column2
   labels:
    - label_column

Excepted result as per the webpage:

# HELP oracledb_custom_sample1 This is my metric number 1
# TYPE oracledb_custom_sample1 gauge
oracledb_custom_sample1{database="mydb",dbinstance="mydb",metric="column1",label_column="some value 1",rownum="1"} 3.14
oracledb_custom_sample1{database="mydb",dbinstance="mydb",metric="column1",label_column="some value 2",rownum="2"} 6.28
oracledb_custom_sample1{database="mydb",dbinstance="mydb",metric="column2",label_column="some value 1",rownum="1"} 1
oracledb_custom_sample1{database="mydb",dbinstance="mydb",metric="column2",label_column="some value 2",rownum="2"} 2

The reuslt which i am getting:

# HELP oracledb_query Self defined Queries from Configuration File.
# TYPE oracledb_query gauge
oracledb_query{column="COLUMN1",database="mydb",dbinstance="mydb",name="sample1",row="1"} 1
oracledb_query{column="COLUMN2",database="mydb",dbinstance="mydb",name="sample1",row="1"} 2
oracledb_query{column="LABEL_COLUMN",database="mydb",dbinstance="mydb",name="sample1",row="1"} 3

In the above result label_column is treated as separate column, instead it should be associated with metrics colum1 and column2 as shown in example of installation part

let us see another scenario

    - sql: "select NAME as db,OPEN_MODE as open,1 as value from v$database"
      name: Status
      labels:
       - db
       - open
      metrics:
       - value

result for above query oracledb_query{column="VALUE",database="mydb",dbinstance="mydb",name="Status",row="1"} 1

here we are just getting value but the labels db,open are not attached with the metric. its of no use getting only the value with no labels. someone please help me how to get labels attached as shown in example of installation part

ChSanjayBabu avatar Aug 12 '20 07:08 ChSanjayBabu

@floyd871 can u please help on this

ChSanjayBabu avatar Aug 12 '20 08:08 ChSanjayBabu

I think this is probably because the columns that you are fetching from v$database in your query (name & Open_mode) are of datatype VARCHAR2.

The readme.md has mentioned that only CHAR, VARCHAR & NUMBER datatypes are supported for the columns being used in Labels. (Check limitations section in custom metrics).

Ofcourse, my understanding could be wrong. To confirm you can check by mentioning a column under label_values that is CHAR, VARCHAR or of Number datatype.

adiithyan avatar Aug 12 '20 09:08 adiithyan

For me, the labels in the example below are not working. Any suggestion?

queries:
 - sql: "select 1 as column1, 2 as column2, 3 as label_column from dual"
   name: sample1
   help: "This is my metric number 1"
   metrics:
    - column1
    - column2
   labels:
    - label_column

alyssonhm avatar Aug 10 '21 14:08 alyssonhm