oracledb_exporter icon indicating copy to clipboard operation
oracledb_exporter copied to clipboard

Errors with multi-DSN features

Open mjnman opened this issue 2 years ago • 10 comments

I'm using the oracledb_exporter version 0.4.3. I using "tnsnames.ora" for db connection and then started the container with DATA_SOURCE_NAME tns alias. In the prometheus configuration i'm using these parameters:

  - job_name: 'oracle_history'
    metrics_path: /metrics
    scrape_interval: 5m
    scrape_timeout: 40s
    static_configs:
      - targets:
        - oracledb_exporter_history:9161

I didn't understand where put the endpoint parameter "/scrape?target=foo:1521" Please, how I can usage this features?

mjnman avatar Mar 03 '23 14:03 mjnman

I tried to configure the job below in prometheus:

  - job_name: 'oracle_history_day'
    metrics_path: /scrape
    scrape_interval: 1m
    scrape_timeout: 40s
    params:
      target: [DB1]
    static_configs:
      - targets:
        - oracledb_exporter_day:9161

curl command returned this error:

 # curl -sS localhost:9161/scrape?target=DB1
An error has occurred while serving metrics:

4 error(s) occurred:
* collected metric "oracledb_exporter_last_scrape_duration_seconds" { gauge:<value:0.000827201 > } was collected before with the same name and label values
* collected metric "oracledb_exporter_last_scrape_error" { gauge:<value:1 > } was collected before with the same name and label values
* collected metric "oracledb_exporter_scrapes_total" { counter:<value:2 > } was collected before with the same name and label values
* collected metric "oracledb_up" { gauge:<value:0 > } was collected before with the same name and label values

and docker logs:

s=2023-03-03T16:32:23.314Z caller=main.go:262 level=error msg="Error pinging oracle" err="ORA-12162: TNS:net service name is incorrectly specified\n"
ts=2023-03-03T16:32:23.520Z caller=main.go:262 level=error msg="Error pinging oracle" err="ORA-12162: TNS:net service name is incorrectly specified\n"

mjnman avatar Mar 03 '23 16:03 mjnman

I modified the job configuration in prometheus and set debug mode in prometheus and oracledb exporter:

Config in prometheus.yml file:

global:
  scrape_interval: 10s

scrape_configs:
  - job_name: 'oracle_history_day'
    metrics_path: /scrape
    scrape_interval: 1m
    scrape_timeout: 40s
    params:
      target:
        - USER/PWD@DB1
    static_configs:
      - targets:
        - oracledb_exporter_day:9161

now from debug logs the query execution from oracledb exporter work correctly:

ts=2023-03-29T13:03:31.233Z caller=main.go:267 level=debug msg="Successfully pinged Oracle database" dsn=***@DB1
ts=2023-03-29T13:03:31.234Z caller=main.go:541 level=debug msg="Checking modifications in following metrics definition" file=/metrics/container-metrics.toml
ts=2023-03-29T13:03:31.234Z caller=main.go:284 level=debug msg="About to scrape metric"
ts=2023-03-29T13:03:31.234Z caller=main.go:285 level=debug metricsDesc="unsupported value type"
ts=2023-03-29T13:03:31.234Z caller=main.go:286 level=debug context=multitarget
ts=2023-03-29T13:03:31.234Z caller=main.go:287 level=debug metricsType="unsupported value type"
ts=2023-03-29T13:03:31.234Z caller=main.go:288 level=debug metricsBuckets="unsupported value type"
ts=2023-03-29T13:03:31.234Z caller=main.go:289 level=debug labels="unsupported value type"
ts=2023-03-29T13:03:31.234Z caller=main.go:290 level=debug fieldToAppend=
ts=2023-03-29T13:03:31.234Z caller=main.go:291 level=debug ignoreZeroResult=false
ts=2023-03-29T13:03:31.234Z caller=main.go:292 level=debug request="SELECT d.name database,COUNT(*) as process FROM v$process p, V$DATABASE D group by d.name"
ts=2023-03-29T13:03:31.234Z caller=main.go:346 level=debug msg="Calling function ScrapeGenericValues()"
ts=2023-03-29T13:03:31.234Z caller=main.go:446 level=debug msg="Calling function GeneratePrometheusMetrics()"
ts=2023-03-29T13:03:31.417Z caller=main.go:372 level=debug msg="Query result looks like" value=230
ts=2023-03-29T13:03:31.420Z caller=main.go:448 level=debug msg=ScrapeGenericValues() metricsCount=1
ts=2023-03-29T13:03:31.420Z caller=main.go:319 level=debug msg="Successfully scraped metric" context=multitarget metricsDesc="unsupported value type" since=185.811834ms

But in the prometheus logs there are a lot of errors:

ts=2023-03-29T13:06:31.403Z caller=scrape.go:1351 level=debug component="scrape manager" scrape_pool=oracle_history_day target="http://oracledb_exporter_day:9161/scrape?target=USER%2FPWD%40DB1" msg="Scrape failed" err="server returned HTTP status 500 Internal Server Error"
ts=2023-03-29T13:07:31.510Z caller=scrape.go:1351 level=debug component="scrape manager" scrape_pool=oracle_history_day target="http://oracledb_exporter_day:9161/scrape?target=USER%2FPWD%40DB1" msg="Scrape failed" err="server returned HTTP status 500 Internal Server Error"
ts=2023-03-29T13:08:31.392Z caller=scrape.go:1351 level=debug component="scrape manager" scrape_pool=oracle_history_day target="http://oracledb_exporter_day:9161/scrape?target=USER%2FPWD%40DB1" msg="Scrape failed" err="server returned HTTP status 500 Internal Server Error"

with the curl command with "/scrape" path obtain an error:

# curl -sS localhost:9161/scrape?target=USER%2FPWD%40DB1
An error has occurred while serving metrics:

4 error(s) occurred:
* collected metric "oracledb_exporter_last_scrape_duration_seconds" { gauge:<value:0.406108562 > } was collected before with the same name and label values
* collected metric "oracledb_exporter_last_scrape_error" { gauge:<value:0 > } was collected before with the same name and label values
* collected metric "oracledb_exporter_scrapes_total" { counter:<value:2 > } was collected before with the same name and label values
* collected metric "oracledb_up" { gauge:<value:1 > } was collected before with the same name and label values

but the execution of curl command with "/metrics" path work correctly but without DSN data of the DB1:

# curl -sS localhost:9161/metrics
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 4.3412e-05
go_gc_duration_seconds{quantile="0.25"} 5.8975e-05
go_gc_duration_seconds{quantile="0.5"} 7.0968e-05
...
...

seems the prometheus didn't pickup the query values. maybe the same issue of "postgres_exporter" -> https://github.com/prometheus-community/postgres_exporter/issues/296

mjnman avatar Mar 29 '23 13:03 mjnman

Hi!

I'm having some problems too trying to understand how the multi target works.

What I understand is that the "target" parameter should be the same DSN as if it was configured directly as the DATA_SOURCE_NAME env variable, so when the request is made the exporter connects to that database, whether defined on the exporter or not.

For example: http://localhost:9161/scrape?target=system/manager@//123.123.123.123:1521/SERVICENAME

After escaping characters: http://localhost:9161/scrape?target=system%2Fmanager%40%2F%2F123.123.123.123%3A1521%2FSERVICENAME

That should scrape metrics from the "target" database. Is thas correct?

I'm using oracledb exporter 0.5.1

xafer337 avatar Jun 02 '23 12:06 xafer337

With oracledb exporter 0.5.1 version the /scrape path don't recognize. In the code I didn't see any reference at /scrape path. I'm using a version 4.4 version with code modified

mjnman avatar Jun 05 '23 14:06 mjnman

Hi~ I have the same issue. Have you resolved this issue yet?

Tiny66 avatar Oct 10 '23 01:10 Tiny66

in the tree 0.4.4 I commented the line 596 -> go exporter.runScheduledScrapes()

mjnman avatar Oct 27 '23 12:10 mjnman

Question, how did you fix the "same name and label values" error?

mvapper avatar Nov 02 '23 09:11 mvapper

Answer, when I edited the code and rebuild the docker I can query oracledb_exporter with TNS alias in the curl string.

DB1: curl -sS localhost:9161/scrape?target=USER/PWD@DB1

DB2: curl -sS localhost:9161/scrape?target=USER/PWD@DB2

and so on.

mjnman avatar Nov 02 '23 10:11 mjnman

That's exactly what I did, I am also using 0.4.4 with tnsnames.ora, self built. Are you sure commenting the line 596 was your only change?

ts=2023-11-02T18:06:31.694Z caller=scrape.go:1384 level=debug component="scrape manager" scrape_pool=estweb target="http://123.123.321.312:9161/scrape?target=system%2Fmanager%40oradb" msg="Scrape failed" err="server returned HTTP status 500 Internal Server Error"

curl http://123.123.321.312:9161/scrape?target=system%2Fmanager%40oradb" An error has occurred while serving metrics:

111 error(s) occurred:

  • collected metric "oracledb_activity_execute_count" { gauge:<value:1.2031855e+07 > } was collected before with the same name and label values
  • collected metric "oracledb_activity_parse_count_total" { gauge:<value:1.989047e+06 > } was collected before with the same name and label values
  • collected metric "oracledb_activity_user_commits" { gauge:<value:25965 > } was collected before with the same name and label values
  • collected metric "oracledb_activity_user_rollbacks" { gauge:<value:15525 > } was collected before with the same name and label values
  • collected metric "oracledb_asm_diskgroup_free" { label:<name:"name" value:"ASM1" > gauge:<value:1.008730112e+09 > } was collected before with the same name and label values

mvapper avatar Nov 02 '23 18:11 mvapper

Got it working at one point. Had to comment few extra lines out. Everything that is collected by default (lines 202-206). Also the key is to start the exporter without DATA_SOURCE_NAME apparently. Not the nicest way, but at least i got it running.

mvapper avatar Nov 04 '23 15:11 mvapper