Git Product home page Git Product logo

Comments (8)

Yannig avatar Yannig commented on May 29, 2024

Value field must be a integer and not a string. I guess you need to remove the decode call.

from oracledb_exporter.

Yannig avatar Yannig commented on May 29, 2024

Here the correct request:

[[metric]]
context = "rman_backup_status"
labels = [ "start_time", "input_type" ]
metricsdesc = { value="Gauge metric with rman backup status (5:FAILED; 4:RUNNING WITH ERRORS; 3:COMPLETED WITH ERRORS; 2:RUNNING WITH WARNINGS; 1:COMPLETED WITH WARNINGS; 0:COMPLETED)." }
request = "SELECT to_char(start_time, 'yyyy-mm-dd hh24:mi:ss') as start_time, input_type, status as value FROM v$rman_backup_job_details WHERE start_time = (SELECT max(start_time) FROM v$rman_backup_job_details)"

from oracledb_exporter.

Yannig avatar Yannig commented on May 29, 2024
SELECT
  to_char(start_time, 'yyyy-mm-dd hh24:mi:ss') as start_time, input_type, status as value
FROM
  v$rman_backup_job_details
WHERE
  start_time = (SELECT max(start_time) FROM v$rman_backup_job_details)

from oracledb_exporter.

Ben2277 avatar Ben2277 commented on May 29, 2024

Thanks Yannig!

I know the Value field must be a integer,so I try to use the decode call to switch the value type such as 'FAILED' --> 5 , the Value field default type is varchar.

Actually, when I use the v$rman_status table,its seems to be ok,but i dont know why. em...

Sorry for disturbing.
Thanks again.

from oracledb_exporter.

Yannig avatar Yannig commented on May 29, 2024

Sorry, I miss the point. Did you try to add TO_NUMBER around decode ?

from oracledb_exporter.

Ben2277 avatar Ben2277 commented on May 29, 2024

Yeah,I have tried it, but still can't parse it.

from oracledb_exporter.

voskampm avatar voskampm commented on May 29, 2024

I had a similar problem with rman metrics and I did some testing. I can confirm that converting VALUE to integer solves the problem:

[[metric]]
context = "rman_backup_status"
labels = [ "start_time", "input_type" ]
metricsdesc = { value="Gauge metric with rman backup status (5:FAILED; 4:RUNNING WITH ERRORS; 3:COMPLETED WITH ERRORS; 2:RUNNING WITH WARNINGS; 1:COMPLETED WITH WARNINGS; 0:COMPLETED)." }
request = '''
SELECT to_char(start_time, 'yyyy-mm-dd hh24:mi:ss') as start_time
,      input_type
,      cast( decode(status, 'FAILED', 5, 'RUNNING WITH ERRORS', 4, 'COMPLETED WITH ERRORS', 3, 'RUNNING WITH WARNINGS', 2, 'COMPLETED WITH WARNINGS', 1, 0) as integer) as value 
FROM v$rman_backup_job_details 
WHERE start_time = (SELECT max(start_time) FROM v$rman_backup_job_details)
'''

Output:

# HELP oracledb_rman_backup_status_value Gauge metric with rman backup status (5:FAILED; 4:RUNNING WITH ERRORS; 3:COMPLETED WITH ERRORS; 2:RUNNING WITH WARNINGS; 1:COMPLETED WITH WARNINGS; 0:COMPLETED).
# TYPE oracledb_rman_backup_status_value gauge
oracledb_rman_backup_status_value{input_type="DB FULL",start_time="2019-09-12 09:48:43"} 5

I am new to Prometheus so correct me if I am wrong: Using input_type and start_time as labels is not the Prometheus way. It would be better to create three metrics:
oracledb_rman_lastbackup_result
oracledb_rman_lastbackup_type
oracledb_rman_lastbackup_starttime

from oracledb_exporter.

Yannig avatar Yannig commented on May 29, 2024

@voskampm

Yes, it is a good practice. You can not do calculations on a label.

from oracledb_exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.