Git Product home page Git Product logo

oracledb_exporter's Introduction

Oracle DB Exporter

Build Status GoDoc Report card

Table of Contents

Description Installation Running Usage Grafana Build Troubleshooting Operating principles

Description

A Prometheus exporter for Oracle modeled after the MySQL exporter. I'm not a DBA or seasoned Go developer so PRs definitely welcomed.

The following metrics are exposed currently.

  • oracledb_exporter_last_scrape_duration_seconds
  • oracledb_exporter_last_scrape_error
  • oracledb_exporter_scrapes_total
  • oracledb_up
  • oracledb_activity_execute_count
  • oracledb_activity_parse_count_total
  • oracledb_activity_user_commits
  • oracledb_activity_user_rollbacks
  • oracledb_sessions_activity
  • oracledb_wait_time_application
  • oracledb_wait_time_commit
  • oracledb_wait_time_concurrency
  • oracledb_wait_time_configuration
  • oracledb_wait_time_network
  • oracledb_wait_time_other
  • oracledb_wait_time_scheduler
  • oracledb_wait_time_system_io
  • oracledb_wait_time_user_io
  • oracledb_tablespace_bytes
  • oracledb_tablespace_max_bytes
  • oracledb_tablespace_free
  • oracledb_tablespace_used_percent
  • oracledb_process_count
  • oracledb_resource_current_utilization
  • oracledb_resource_limit_value

Installation

Docker / Podman

You can run via Docker/Podman using an existing image. Since version 0.4, the images are available on the github registry.

Here an example to retrieve the version 0.5.0:

docker pull ghcr.io/iamseth/oracledb_exporter:0.5.0

And here a command to run it and forward the port:

docker run -it --rm -p 9161:9161 ghcr.io/iamseth/oracledb_exporter:0.5.0

If you don't already have an Oracle server, you can run one locally in a container and then link the exporter to it.

docker run -d --name oracle -p 1521:1521 wnameless/oracle-xe-11g-r2:18.04-apex
docker run -d --name oracledb_exporter --link=oracle -p 9161:9161 -e DATA_SOURCE_NAME=oracle://system:oracle@oracle:1521/xe ghcr.io/iamseth/oracledb_exporter:0.5.0

Since 0.2.1, the exporter image exist with Alpine flavor. Watch out for their use. It is for the moment a test.

docker run -d --name oracledb_exporter --link=oracle -p 9161:9161 -e DATA_SOURCE_NAME=oracle://system:oracle@oracle/xe iamseth/oracledb_exporter:alpine

Different Docker Images

Different Linux Distros:

  • x.y.z - Ubuntu Linux image
  • x.y.z-oraclelinux - Oracle Enterprise Linux image
  • x.y.z-Alpine - Alpine Linux image
  • x.y.z-scratch - Scratch image

Forked Version: All the above docker images have a duplicate image tag ending in _legacy-tablespace. These versions use the older/deprecated tablespace utilization calculation based on the aggregate sum of file sizes in a given tablespace. The newer mechanism takes into account block sizes, extents, and fragmentation aligning with the same metrics reported from the Oracle Enterprise Manager. See #153 for details. The versions above should have a more useful tablespace utilization calculation going forward.

Binary Release

Pre-compiled versions for Linux 64 bit and Mac OSX 64 bit can be found under releases.

In order to run, you'll need the Oracle Instant Client Basic for your operating system. Only the basic version is required for execution.

Running

Ensure that the environment variable DATA_SOURCE_NAME is set correctly before starting. DATA_SOURCE_NAME should be in Oracle Database connection string format:

    oracle://user:pass@server/service_name[?OPTION1=VALUE1[&OPTIONn=VALUEn]...]

For Example:

# export Oracle location:
export DATA_SOURCE_NAME=oracle://system:password@oracle-sid
# or using a complete url:
export DATA_SOURCE_NAME=oracle://user:password@myhost:1521/service
# 19c client for primary/standby configuration
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/service
# 19c client for primary/standby configuration with options
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/service?connect_timeout=5&transport_connect_timeout=3&retry_count=3
# 19c client for ASM instance connection (requires SYSDBA)
export DATA_SOURCE_NAME=oracle://user:password@primaryhost:1521,standbyhost:1521/+ASM?as=sysdba
# Then run the exporter
/path/to/binary/oracledb_exporter --log.level error --web.listen-address 0.0.0.0:9161

Version 0.5+ of the exporter is using a go lang driver that don't need the binaries from Oracle. As a side effect, you must transform your string version in order to be compatible with this driver.

Basicaly, it consist to follow this convention:

  • Add a string oracle:// in front of the string
  • Replace the slash (/) between user and password by a colon (:)
  • special characters should be url-escaped, like in this jinja example template: {{ password|urlencode()|regex_replace('/','%2F') }}

Here is some example:

Old string format New string format
system/password@oracle-sid oracle://system:password@oracle-sid
user/password@myhost:1521/service oracle://user:password@myhost:1521/service

Default-metrics requirement

Make sure to grant SYS privilege on SELECT statement for the monitoring user, on the following tables.

dba_tablespace_usage_metrics
dba_tablespaces
v$system_wait_class
v$asm_diskgroup_stat
v$datafile
v$sysstat
v$process
v$waitclassmetric
v$session
v$resource_limit

Integration with System D

Create oracledb_exporter user with disabled login and oracledb_exporter group then run the following commands:

mkdir /etc/oracledb_exporter
chown root:oracledb_exporter /etc/oracledb_exporter
chmod 775 /etc/oracledb_exporter
Put config files to **/etc/oracledb_exporter**
Put binary to **/usr/local/bin**

Create file /etc/systemd/system/oracledb_exporter.service with the following content:

[Unit]
Description=Service for oracle telemetry client
After=network.target
[Service]
Type=oneshot
#!!! Set your values and uncomment
#User=oracledb_exporter
#Environment="CUSTOM_METRICS=/etc/oracledb_exporter/custom-metrics.toml"
ExecStart=/usr/local/bin/oracledb_exporter  \
  --default.metrics "/etc/oracledb_exporter/default-metrics.toml"  \
  --log.level error --web.listen-address 0.0.0.0:9161
[Install]
WantedBy=multi-user.target

Tell System D to refresh:

systemctl daemon-reload

Start this new service:

systemctl start oracledb_exporter

Check service status:

systemctl status oracledb_exporter

Usage

Usage of oracledb_exporter:
  --log.format value
       	If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.
  --log.level value
       	Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].
  --custom.metrics string
        File that may contain various custom metrics in a toml or yaml format.
  --default.metrics string
        Default metrics file in a toml or yaml format.
  --web.systemd-socket
        Use systemd socket activation listeners instead of port listeners (Linux only).
  --web.listen-address string
       	Address to listen on for web interface and telemetry. (default ":9161")
  --web.telemetry-path string
       	Path under which to expose metrics. (default "/metrics")
  --database.maxIdleConns string
        Number of maximum idle connections in the connection pool. (default "0")
  --database.maxOpenConns string
        Number of maximum open connections in the connection pool. (default "10")
  --database.dsn string
        Connection string to a data source. (default "env: DATA_SOURCE_NAME")
  --database.dsnFile string
        File to read a string to a data source from. (default "env: DATA_SOURCE_NAME_FILE")        
  --web.config.file
        Path to configuration file that can enable TLS or authentication.
  --query.timeout
        Query timeout (in seconds). (default "5")
  --scrape.interval
        Interval between each scrape. Default "0s" is to scrape on collect requests

Default metrics config file

This exporter comes with a set of default metrics: default-metrics.toml/default-metrics.yaml.
You can modify this file or provide a different one using default.metrics option.

Custom metrics config file

NOTE: Do not put a ; at the end of your SQL queries as this will NOT work.

This exporter does not have the metrics you want? You can provide new one using custom metrics config file in a toml or yaml format. To specify this file to the exporter, you can:

  • Use --custom.metrics flag followed by your custom config file
  • Export CUSTOM_METRICS variable environment (export CUSTOM_METRICS=<path-to-custom-configfile>)

Config file TOML syntax

The file must contain the following elements:

  • One or several metric section ([[metric]])
  • For each section a context, a request and a map between a field of your request and a comment.

Here's a simple example:

[[metric]]
context = "test"
request = "SELECT 1 as value_1, 2 as value_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1.", value_2 = "Same but returning always 2." }

This file produce the following entries in the exporter:

# HELP oracledb_test_value_1 Simple example returning always 1.
# TYPE oracledb_test_value_1 gauge
oracledb_test_value_1 1
# HELP oracledb_test_value_2 Same but returning always 2.
# TYPE oracledb_test_value_2 gauge
oracledb_test_value_2 2

You can also provide labels using labels field. Here's an example providing two metrics, with and without labels:

[[metric]]
context = "context_no_label"
request = "SELECT 1 as value_1, 2 as value_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1.", value_2 = "Same but returning always 2." }

[[metric]]
context = "context_with_labels"
labels = [ "label_1", "label_2" ]
request = "SELECT 1 as value_1, 2 as value_2, 'First label' as label_1, 'Second label' as label_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1.", value_2 = "Same but returning always 2." }

This TOML file produce the following result:

# HELP oracledb_context_no_label_value_1 Simple example returning always 1.
# TYPE oracledb_context_no_label_value_1 gauge
oracledb_context_no_label_value_1 1
# HELP oracledb_context_no_label_value_2 Same but returning always 2.
# TYPE oracledb_context_no_label_value_2 gauge
oracledb_context_no_label_value_2 2
# HELP oracledb_context_with_labels_value_1 Simple example returning always 1.
# TYPE oracledb_context_with_labels_value_1 gauge
oracledb_context_with_labels_value_1{label_1="First label",label_2="Second label"} 1
# HELP oracledb_context_with_labels_value_2 Same but returning always 2.
# TYPE oracledb_context_with_labels_value_2 gauge
oracledb_context_with_labels_value_2{label_1="First label",label_2="Second label"} 2

Last, you can set metric type using metricstype field.

[[metric]]
context = "context_with_labels"
labels = [ "label_1", "label_2" ]
request = "SELECT 1 as value_1, 2 as value_2, 'First label' as label_1, 'Second label' as label_2 FROM DUAL"
metricsdesc = { value_1 = "Simple example returning always 1 as counter.", value_2 = "Same but returning always 2 as gauge." }
# Can be counter or gauge (default)
metricstype = { value_1 = "counter" }

This TOML file will produce the following result:

# HELP oracledb_context_with_labels_value_1 Simple example returning always 1 as counter.
# TYPE oracledb_context_with_labels_value_1 counter
oracledb_context_with_labels_value_1{label_1="First label",label_2="Second label"} 1
# HELP oracledb_context_with_labels_value_2 Same but returning always 2 as gauge.
# TYPE oracledb_context_with_labels_value_2 gauge
oracledb_context_with_labels_value_2{label_1="First label",label_2="Second label"} 2

You can find here a working example of custom metrics for slow queries, big queries and top 100 tables.

Config file YAML syntax

yaml format has the same as the above requirements regarding optional and mandatory fields and their meaning, but needs a root element metric:

metrics:
- context: "context_with_labels"
  labels: [label_1,label_2]
  metricsdesc:
    value_1: "Simple example returning always 1 as counter."
    value_2: "Same but returning always 2 as gauge."
  request: "SELECT 'First label' as label_1, 'Second label' as label_2,
    1 as value_1, 2 as value_2
    FROM DUAL"
  metricstype:
    value_1: "counter"

For more practical examples, see custom-metrics.yaml

Customize metrics in a docker image

If you run the exporter as a docker image and want to customize the metrics, you can use the following example:

FROM iamseth/oracledb_exporter:latest

COPY custom-metrics.toml /

ENTRYPOINT ["/oracledb_exporter", "--custom.metrics", "/custom-metrics.toml"]

Using a multiple host data source name

NOTE: This has been tested with v0.2.6a and will most probably work on versions above.

NOTE: While user/password@//database1.example.com:1521,database3.example.com:1521/DBPRIM works with SQLPlus, it doesn't seem to work with oracledb-exporter v0.2.6a.

In some cases, one might want to scrape metrics from the currently available database when having a active-passive replication setup.

This will try to connect to any available database to scrape for the metrics. With some replication options, the secondary database is not available when replicating. This allows the scraper to automatically fall back in case of the primary one failing.

This example allows to achieve this:

Files & Folder:

  • tns_admin folder: /path/to/tns_admin
  • tnsnames.ora file: /path/to/tns_admin/tnsnames.ora

Example of a tnsnames.ora file:

database =
(DESCRIPTION =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = database1.example.com)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = database2.example.com)(PORT = 1521))
  )
  (CONNECT_DATA =
    (SERVICE_NAME = DBPRIM)
  )
)

Environment Variables

  • TNS_ENTRY: Name of the entry to use (database in the example file above)
  • TNS_ADMIN: Path you choose for the tns admin folder (/path/to/tns_admin in the example file above)
  • DATA_SOURCE_NAME: Datasource pointing to the TNS_ENTRY (user:password@database in the example file above)

TLS connection to database

First, set the following variables:

export WALLET_PATH=/wallet/path/to/use
export TNS_ENTRY=tns_entry
export DB_USERNAME=db_username
export TNS_ADMIN=/tns/admin/path/to/use

Create the wallet and set the credential:

mkstore -wrl $WALLET_PATH -create
mkstore -wrl $WALLET_PATH -createCredential $TNS_ENTRY $DB_USERNAME

Then, update sqlnet.ora:

echo "
WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = $WALLET_PATH )))
SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
" >> $TNS_ADMIN/sqlnet.ora

To use the wallet, use the wallet_location parameter. You may need to disable ssl verification with the ssl_server_dn_match parameter.

Here a complete example of string connection:

DATA_SOURCE_NAME=oracle://username:password@server:port/service?ssl_server_dn_match=false&wallet_location=wallet_path

For more details, have a look at the following location: #84

Integration with Grafana

An example Grafana dashboard is available here.

Build

Docker/Podman build

To build Ubuntu and Alpine image, run the following command:

make docker

You can also build only Ubuntu image:

make ubuntu-image

Or Alpine:

make alpine-image

Or Scratch:

make scratch-image

Building Binaries

Run build:

    make go-build

will output binaries and archive inside the dist folder for the building operating system.

Import into your Golang Application

The oracledb_exporter can also be imported into your Go based applications. The Grafana Agent uses this pattern to implement the OracleDB integration. Feel free to modify the code to fit your application's use case.

Here is a small snippet of an example usage of the exporter in code:

 promLogConfig := &promlog.Config{}
 // create your own config
 logger := promlog.New(promLogConfig)

 // replace with your connection string
 connectionString := "oracle://username:password@localhost:1521/orcl.localnet"
 oeExporter, err := oe.NewExporter(logger, &oe.Config{
  DSN:          connectionString,
  MaxIdleConns: 0,
  MaxOpenConns: 10,
  QueryTimeout: 5,
 })

 if err != nil {
  panic(err)
 }

 metricChan := make(chan prometheus.Metric, len(oeExporter.DefaultMetrics().Metric))
 oeExporter.Collect(metricChan)

 // alternatively its possible to run scrapes on an interval
 // and Collect() calls will only return updated data once
 // that intervaled scrape is run
 // please note this is a blocking call so feel free to run
 // in a separate goroutine
 // oeExporter.RunScheduledScrapes(context.Background(), time.Minute)

 for r := range metricChan {
  // Write to the client of your choice
  // or spin up a promhttp.Server to serve these metrics
  r.Write(&dto.Metric{})
 }

FAQ/Troubleshooting

Unable to convert current value to float (metric=par,metri...in.go:285

Oracle is trying to send a value that we cannot convert to float. This could be anything like 'UNLIMITED' or 'UNDEFINED' or 'WHATEVER'.

In this case, you must handle this problem by testing it in the SQL request. Here an example available in default metrics:

[[metric]]
context = "resource"
labels = [ "resource_name" ]
metricsdesc = { current_utilization= "Generic counter metric from v$resource_limit view in Oracle (current value).", limit_value="Generic counter metric from v$resource_limit view in Oracle (UNLIMITED: -1)." }
request="SELECT resource_name,current_utilization,CASE WHEN TRIM(limit_value) LIKE 'UNLIMITED' THEN '-1' ELSE TRIM(limit_value) END as limit_value FROM v$resource_limit"

If the value of limit_value is 'UNLIMITED', the request send back the value -1.

You can increase the log level (--log.level debug) in order to get the statement generating this error.

error while loading shared libraries: libclntsh.so.xx.x: cannot open shared object file: No such file or directory

Version before 0.5 use libs from Oracle in order to connect to Oracle Database. After 0.5 release, the oracle exporter use an pure Go DB driver and don't need binaries from Oracle anymore.

Please switch to version 0.5.

For older version, you must install the Oracle binaries somewhere on your machine and you must install the good version number. If the error talk about the version 18.3, you must install 18.3 binary version. If it's 12.2, you must install 12.2.

An alternative is to run this exporter using a Docker container. This way, you don't have to worry about Oracle binaries version as they are embedded in the container.

Here an example to run this exporter (to scrap metrics from system/oracle@//host:1521/service-or-sid) and bind the exporter port (9161) to the global machine:

docker run -it --rm -p 9161:9161 -e DATA_SOURCE_NAME=oracle://system/oracle@//host:1521/service-or-sid iamseth/oracledb_exporter:0.2.6a

Error scraping for wait_time

If you experience an error Error scraping for wait_time: sql: Scan error on column index 1: converting driver.Value type string (",01") to a float64: invalid syntax source="main.go:144" you may need to set the NLS_LANG variable.

export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export DATA_SOURCE_NAME=system/oracle@myhost
/path/to/binary --log.level error --web.listen-address :9161

If using Docker, set the same variable using the -e flag.

An Oracle instance generates a lot of trace files being monitored by exporter

As being said, Oracle instance may (and probably does) generate a lot of trace files alongside its alert log file, one trace file per scraping event. The trace file contains the following lines

...
*** MODULE NAME:(prometheus_oracle_exporter-amd64@hostname)
...
kgxgncin: clsssinit: CLSS init failed with status 3
kgxgncin: clsssinit: return status 3 (0 SKGXN not av) from CLSS

The root cause is Oracle's reaction of quering ASM-related views without ASM used. The current workaround proposed is to setup a regular task to cleanup these trace files from the filesystem, as example

$ find $ORACLE_BASE/diag/rdbms -name '*.tr[cm]' -mtime +14 -delete

TLS and basic authentication

Apache Exporter supports TLS and basic authentication. This enables better control of the various HTTP endpoints.

To use TLS and/or basic authentication, you need to pass a configuration file using the --web.config parameter. The format of the file is described in the exporter-toolkit repository.

Note that the TLS and basic authentication settings affect all HTTP endpoints: /metrics for scraping, /probe for probing, and the web UI.

Multi-target support

This exporter supports the multi-target pattern. This allows running a single instance of this exporter for multiple Oracle targets.

To use the multi-target functionality, send a http request to the endpoint /scrape?target=foo:1521 where target is set to the DSN of the Oracle instance to scrape metrics from.

oracledb_exporter's People

Contributors

billabongrob avatar caiwc avatar daviddetorres avatar dependabot[bot] avatar developandroidninja avatar dmaganto avatar hansk-p avatar iamseth avatar jessp01 avatar lucian-vanghele avatar mak0tin avatar man-at-home avatar marinafrank avatar markruler avatar marquizee avatar mrjimroll avatar neilschelly avatar oskarspakers avatar pango853 avatar patrickschilder avatar pelov avatar pnrmx avatar schmikei avatar voskampm avatar vsile avatar vutkin avatar vvelikodny avatar yannig avatar zabuqasem avatar zopanix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oracledb_exporter's Issues

"Error scraping for server_session : No metrics found while parsing - COUNT

Hi,
i see that this error is common and sql response should be integer.. but i am doing count. which is number and therefore integer

this is metric config

[[metric]]
context = "server_session"
labels = [ "server_1" ]
request = "select count(case when machine ='server01' then 1 end) as server_1 from v$session WHERE TYPE <> 'BACKGROUND'"
metricsdesc = { server_1 = "Session on server01" }
metricstype = { server_1 = "counter" }

if i do plain select count(*) from v$session it looks fine

thanks
tomislav

Scraping error with wait_time metrics

Hello,

Error scraping for wait_time: sql: Scan error on column index 1: converting driver.Value type string (",01") to a float64: invalid syntax source="main.go:144"

I have also the same problem with any metrics returned in float64 from a sql request, did you know how to fix it ? Thx in advance

Cannot display metrics that added in the my-custom-metrics.toml on Grafana

Hi,
Thanks a lot for your exporter, it helps a lot for my job!
Here is question that I encountered during using this exporter, that is:

1、I have added a metric via my-custom-metrics.toml_

[[metric]]
context = "libraryCache"
labels = ["namespace"]
metricsdesc = { pinhits= "objects in cache", pins="all of the objects that executed", reloads="Total reload counts", invalidations="Metric with objects miss counts"}
request = "SELECT namespace, pinhits, pins, reloads, invalidations FROM v$librarycache"
metricstype = { namespace= "gauge" }

2、I can also get the metrics via Prometheus http://XXXXX:9090

oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="ACCOUNT_STATUS"} 0
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="BODY"} 110107
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="CLUSTER"} 1800
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="DBINSTANCE"} 0
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="DBLINK"} 0
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="DIRECTORY"} 16
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="EDITION"} 2294
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="INDEX"} 5548
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="OBJECT ID"} 0
oracledb_libraryCache_pins{instance="oracle",job="rac_oracle",namespace="QUEUE"}

3、The question is I cannot get the value of metrics via Grafana??

Regarding for your answers!
Thanks a lot!

Metric Scrape error

Hi,

I'm using custom metric to collect some space usage. But this metric is not scraping
Here is my query "select round((space_used-space_reclaimable)*100/space_limit,1) fra_usage from v$recovery_file_dest";

When i tested i cannot add metric request using this views v$recovery_file_dest, v$recovery_area_usage.
Other system views like v$sysmetric work fine.

What am i doing wrong?

Thanks,

Increase connect timeout value

Hello

Is it possible to increase queryTimeout from 5 to 10 seconds?
https://github.com/iamseth/oracledb_exporter/blob/master/main.go#L30

Or may be make it as environment variable.

We have a big database and from time to time some queries are slow, and on output we are getting intermittent graphs in grafana

By the way, I have tried to build and image by myself and got the next error

 ---> Running in 7f53a86f6a14
github.com/BurntSushi/toml
oracledb_exporter/vendor/github.com/mattn/go-oci8
# oracledb_exporter/vendor/github.com/mattn/go-oci8
vendor/github.com/mattn/go-oci8/oci8.go:4:17: fatal error: oci.h: No such file or directory
 #include <oci.h>
                 ^
compilation terminated.
oracledb_exporter/vendor/github.com/beorn7/perks/quantile
oracledb_exporter/vendor/github.com/golang/protobuf/proto
oracledb_exporter/vendor/github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
oracledb_exporter/vendor/github.com/prometheus/common/model
oracledb_exporter/vendor/github.com/prometheus/procfs
oracledb_exporter/vendor/github.com/Sirupsen/logrus
oracledb_exporter/vendor/github.com/prometheus/client_model/go
oracledb_exporter/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil
oracledb_exporter/vendor/github.com/prometheus/common/log
oracledb_exporter/vendor/github.com/prometheus/common/expfmt
oracledb_exporter/vendor/github.com/prometheus/client_golang/prometheus
The command '/bin/sh -c go build -v -ldflags "-X main.Version=${VERSION} -s -w"' returned a non-zero code: 2```

Could you please help?

Thanks

Versions 0.2.1 and above don't work with Oracle client 12.2

This is probably tangentially related to #34, but I want to continue discussion here.

TL;DR -- the Linux releases of versions 0.2.2 and 0.2.1 do not work with Oracle Client 12.2. I'm guessing this is due to cf9761d or ab9debd, but I wanted to confirm that this is expected behavior.

Is there some way to compile the binary in a way that allows for different versions of Oracle client to be installed on the target system?

Add custom oracle metric/query over external config file

Hello @iamseth, I appreciate your work, the oracledb_exporter you built is usable.
It would be really helpful if the oracle sql query would not be hard coded into the exporter.
The exporter would provide much more flexibility if each user could add his custom SQL query and associate a metric name to it over an external config file.
It is not difficult to change the code you provided and add additional query or replace existing ones but it would make more sense to keep the code and the versioning managed by you and the config file with each query/metric separated.
Let me know if you consider improving the oracledb_exporter as I suggested.
Thank you.
K.

./oracledb_exporter: error while loading shared libraries: libclntsh.so.18.1: cannot open shared object file: No such file or directory

My Oracle version is 11.2.0.4。when I execute the command below:
[oracle@db oracledb_exporter.0.2.2.linux-amd64]$ ./oracledb_exporter
i found below information:
./oracledb_exporter: error while loading shared libraries: libclntsh.so.18.1: cannot open shared object file: No such file or directory

and my lib below:
[root@db opt]# find / -name libclntsh.*
/tmp/OraInstall2017-05-15_10-41-31AM/ext/lib/libclntsh.so.11.1
/u01/app/product/11.2.0/db_1/inventory/backup/2017-05-15_10-41-43AM/Scripts/ext/lib/libclntsh.so.11.1
/u01/app/product/11.2.0/db_1/inventory/Scripts/ext/lib/libclntsh.so.11.1
/u01/app/product/11.2.0/db_1/lib/libclntsh.so
/u01/app/product/11.2.0/db_1/lib/libclntsh.so.10.1
/u01/app/product/11.2.0/db_1/lib/libclntsh.so.11.1

libclntsh.so.18.1: cannot open shared object file

[root@ecs003 oracle_exporter]# ./oracledb_exporter -h
./oracledb_exporter: error while loading shared libraries: libclntsh.so.18.1: cannot open shared object file: No such file or directory
[root@ecs003 oracle_exporter]# find / -iname "libclntsh*.*" -type f
/usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1

oracle_exporter version:oracledb_exporter.0.2.1
oracle client version:11.2.0.4.0

why oracledb_exporter depend on libclntsh.so.18.1?

Anyway to limit or control the metrics collection time?

Hi,

I don't know how often does the exporter run the queries against the DB, is it like every minute, five minutes, etc.
I am asking as the use case is like, we may not want to metrics that often and some more often.
Is it possible to explicitly configure this somewhere?

Please excuse my question(or my lack of Prometheus way) as I am coming from ELK and metricbeat, where the metrics generation interval can be set for each module(exporter) and I am using this exporter for just Oracle DB.

Any ways to configure this exporter?

The default scape interval 5s is too frequent for some targets. How can I change it except Modifing the source code? Further more,maybe different targets need different scape interval. Besides, is there any ways to configure other parameters, such as the size of cashed data,log file and so on.

Unable to connect as / as sysdba

Hi all,
i'm testing 0.2.2 precompilated version for linux
i tried to configure the dsn with something like :
DATA_SOURCE_NAME="/@myservice as ssydba"
but it seems not supported.
The idea is monitoring the databases from the database server itself without managing dedicated monitoring user and password for every database.

Do you think this kind of feature is possible ?

Thanks a lot!

Error scraping for rman_backup_status : No metrics found while parsing source=main.go:188

Hi,

I'm using custom metric to collect my database information, but when i start my oracledb_exporter, I got the problem:

$ ./oracledb_exporter -log.format "logger:syslog?appname=oracledb_exporter&local=1" -log.level info -default.metrics oracledb-metrics.toml
INFO[0000] Starting oracledb_exporter 0.2.2              source=main.go:335
ERRO[0000] Error scraping for rman_backup_status : No metrics found while parsing  source=main.go:188

This is my metrics :

[[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, decode(status, 'FAILED', 5, 'RUNNING WITH ERRORS', 4, 'COMPLETED WITH ERRORS', 3, 'RUNNING WITH WARNINGS', 2, 'COMPLETED WITH WARNINGS', 1, 0) as value FROM v$rman_backup_job_details WHERE start_time = (SELECT max(start_time) FROM v$rman_backup_job_details)"

Execute in sqlplus:

SELECT to_char(start_time, 'yyyy-mm-dd hh24:mi:ss') as start_time, 
             input_type, 
             decode(status, 'FAILED', 5, 'RUNNING WITH ERRORS', 4, 'COMPLETED WITH ERRORS', 3, 'RUNNING WITH WARNINGS', 2, 'COMPLETED WITH WARNINGS', 1, 0) as value 
  FROM v$rman_backup_job_details 
WHERE start_time = (SELECT max(start_time) FROM v$rman_backup_job_details);

START_TIME          INPUT_TYPE         VALUE
------------------- ------------- ----------
2019-07-21 19:00:22 DB INCR                1

the result is always only one row,what am i doing wrong?

Thanks,

The parameter web.listen-address has some problem. Is this a bug?

`[root@gujp-server0005 oracledb_exporter.0.2.3.linux-amd64]# ./oracledb_exporter -log.level=debug -query.timeout=15 -web.listen-address=9162

INFO[0000] Starting oracledb_exporter 0.2.3 source=main.go:337

INFO[0000] Listening on 9162 source=main.go:359

FATA[0000] listen tcp: address 9162: missing port in address source=main.go:360
`

If I delete the parameter web.listen-address, it works fine.
`[root@gujp-server0005 oracledb_exporter.0.2.3.linux-amd64]# ./oracledb_exporter -log.level=debug -query.timeout=15

INFO[0000] Starting oracledb_exporter 0.2.3 source=main.go:337

INFO[0000] Listening on :9161 source=main.go:359
`

custom metrics via select.

Hi,

I would like to add a custom query (sql select read from config) that generates a gauge per row. I have some backend devs here who could like to formulate a query/view best.

will be my first go code :-) , i nearly got lost compiling the thing on windows (the oracle driver parts).

my idea would be like:

content, err := ioutil.ReadFile(*configFile)
err = yaml.Unmarshal(content, &config)

// ScrapeCustomSQL collects a custom query wiith name/value columns in its rows.
func ScrapeCustomSQL(db *sql.DB, ch chan<- prometheus.Metric, config.sqlQuery string) error 
..
 rows.Scan(&name, &value)

ch <- prometheus.MustNewConstMetric(
     prometheus.NewDesc(prometheus.BuildFQName(namespace, "custom", name),
        "Generic counter metric from sql in Oracle.", []string{}, nil),
    prometheus.GaugeValue,
    value,

DATA_SOURCE_NAME example

Would it be possible to provide some data_source_example with password?

I have small to 0 knowledge on Oracle and i am failing to setup a string with username, password, host, port and database

unknown driver "oci8" error

Hello,

When running release 0.22 (oracledb_exporter.0.2.2.darwin-amd64) I get the following when trying to execute:

/oracledb_exporter -log.level error -web.listen-address 9161
ERRO[0000] Error while connecting to user/password@MY_CONN source=main.go:76
panic: sql: unknown driver "oci8" (forgotten import?)

goroutine 1 [running]:
main.NewExporter(0xc000018041, 0x1b, 0x0)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:77 +0x509
main.main()
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:351 +0x1d1

I do have the DATA_SOURCE_NAME environment variable set and have verified connectivity to the DB using oracle client. Thank you for your time and consideration!

No metrics found while parsing" source="main.go:190"

[[metric]]
context = "recovery_file_dest"
labels = [ "name" ]
metricsdesc = { bytes="recovery dest total size",usebytes="used sizes",reusebytes="reclaime size" }
request = '''
SELECT t.NAME as "name",
decode(t.SPACE_LIMIT, 0, '-1', t.SPACE_LIMIT) as "bytes",
decode(t.SPACE_USED, 0, '-1', t.SPACE_USED) as "usebytes",
decode(t.SPACE_RECLAIMABLE, 0, '-1', t.SPACE_RECLAIMABLE) as "reusebytes"
from v$recovery_file_dest t
'''

Error pinging oracle: ORA-12537: TNS:connection closed

Excuse me, I met a question after the oracledb_exporter be running after more hours, the output occurs this:

ERRO[1942] Error pinging oracle: ORA-12537: TNS:connection closed source=main.go:136
ERRO[1947] Error pinging oracle: ORA-12537: TNS:connection closed source=main.go:136
ERRO[1952] Error pinging oracle: ORA-12537: TNS:connection closed source=main.go:136

Due to this, the path http://localhost:9161/metrics couldn't return any metric.

I use a image of webdizz/oracle-xe-11g-sa:latest up for oracle db.
After some research I login into the oracle container to tail the tnslnr listener.log:

tail -f /u01/app/oracle/diag/tnslsnr/cb2abd620214/listener/trace/listener.log

Thu Jun 29 03:45:31 2017
29-JUN-2017 03:45:31 * service_update * XE * 0
29-JUN-2017 03:45:34 * service_update * XE * 0
Thu Jun 29 03:46:15 2017
WARNING: Subscription for node down event still pending
29-JUN-2017 03:46:15 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=cb2abd620214)(USER=root))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=1866470
40)) * status * 0
WARNING: Subscription for node down event still pending
29-JUN-2017 03:46:18 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=cb2abd620214)(USER=root))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=1866470
40)) * status * 0
Thu Jun 29 03:47:17 2017
No longer listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE)))
No longer listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cb2abd620214)(PORT=1521)))
No longer listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=cb2abd620214)(PORT=8080))(Presentation=HTTP)(Session=RAW))

can't get the ORACLE fra information

Hi all,
I can't get the ORACLE fra information.But if I replace v$flash_recovery_area_usage with v$session, it works.

default-metrics.toml
[[metric]]
context = "test"
metricsdesc = { value = "oracle fra" }
request = "select sum(percent_space_used) as value from v$flash_recovery_area_usage"

[[metric]]
context = "test1"
metricsdesc = { value = "oracle fra" }
request = "select count(0) as value from v$flash_recovery_area_usage"

error.log
{"level":"error","msg":"Error scraping for test : No metrics found while parsing","source":"main.go:190","time":"2019-11-27T16:32:12+08:00"}
{"level":"error","msg":"Error scraping for test1 : No metrics found while parsing","source":"main.go:190","time":"2019-11-27T16:32:12+08:00"}

$ echo $DATA_SOURCE_NAME
dbmon/XXXXXXXXXX@test
$ sqlplus dbmon/XXXXXXXXXX@test

SQL*Plus: Release 11.2.0.4.0 Production on Wed Nov 27 16:38:52 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select sum(percent_space_used) as value from v$flash_recovery_area_usage;

 VALUE

  9.36

SQL> select count(0) as value from v$flash_recovery_area_usage;

 VALUE

 7

Need to display more than 2 values to the output in table format

We are planning to customize(.go) for our needs and would like to display multiple(fields) strings in the output using table format but we are getting the below error when we try to display that . can some one please help us to how to can add this functionality .go file to display more than 2 values in the grafana.

panic: inconsistent label cardinality: expected 2 label values but got 4 in []string{"STATUS", "!stdayofthe month", "sameday", "XXX"}
like as shown below

XXX "1st day of the month" "someday" "Running"

Any help would be much appreciated.

Increasing use of memory when running exporter on standby db

In our environment (linux) we are using oracle with one active db and one standby.
What we are seeing when running the exporter on the standby machine, is that the exporter is consuming more and more memory.
Eventually the memory consumption will go up to 80%.

ERRO[1477] Error pinging oracle: ORA-01033: ORACLE initialization or shutdown in progress
source=main.go:168
INFO[1477] Try to reconnect... source=main.go:171
ERRO[1477] Unable to connect to oracle:ORA-01033: ORACLE initialization or shutdown in progress
source=main.go:179

I'm using Oracle instant client 12.2

On the active db the exporter is behaving normally and stays around 0.1 / 0.2 %

I ran a build using the latest version of the code.

can not start oracledb-exporer after add Custom metrics

time="2019-09-27T11:39:10+08:00" level=info msg="Starting oracledb_exporter 0.2.3" source="main.go:337"
panic: interface conversion: interface {} is nil, not string

goroutine 36 [running]:
main.GeneratePrometheusMetrics(0xc000186240, 0xc0001642a0, 0xc0001c80d4, 0x39f, 0x0, 0x0)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:313 +0x6a0
main.ScrapeGenericValues(0xc000186240, 0xc0001b4180, 0xc000188710, 0xd, 0xc00018e400, 0x4, 0x4, 0xc000180f90, 0x0, 0x0, ...)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:260 +0x11d
main.ScrapeMetric(0xc000186240, 0xc0001b4180, 0xc000188710, 0xd, 0xc00018e400, 0x4, 0x4, 0xc000180f90, 0x0, 0x0, ...)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:216 +0xe8
main.(*Exporter).scrape(0xc0001686c0, 0xc0001b4180)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:189 +0x21a
main.(*Exporter).Collect(0xc0001686c0, 0xc0001b4180)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:145 +0x3c
main.(*Exporter).Describe(0xc0001686c0, 0xc000168720)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/main.go:137 +0xb0
github.com/iamseth/oracledb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*registry).Register.func1(0x7ebf80, 0xc0001686c0, 0xc000168720)
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:218 +0x3b
created by github.com/iamseth/oracledb_exporter/vendor/github.com/prometheus/client_golang/prometheus.(*registry).Register
/home/travis/gopath/src/github.com/iamseth/oracledb_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:217 +0xa2

Error scraping for tablespace : Oracle query timed out

[root@ecs-01 oracledb_exporter.0.2.1.linux-amd64]# ./oracledb_exporter -log.level debug -web.listen-address :9161 -default.metrics default-metrics.toml
INFO[0000] Starting oracledb_exporter 0.2.1 source=main.go:323
ERRO[0012] Error scraping for tablespace : Oracle query timed out source=main.go:176
INFO[0012] Listening on :9161 source=main.go:345
ERRO[0029] Error scraping for tablespace : Oracle query timed out source=main.go:176
ERRO[0045] Error scraping for tablespace : Oracle query timed out source=main.go:176
ERRO[0058] Error scraping for tablespace : Oracle query timed out source=main.go:176

What is the reason for this mistake?

dashboards

Hi - do you have any dashboards for grafana laying around - could maybe be checked in and follow the code and/or shared at grafana.net ?

New release

Hi, Can we get a new release with the fixed typo?

fatal error: oci.h: No such file or directory

There was a fatal error occurs when I executed go get github.com/mattn/go-oci8 and copy oci8.pc file and then go get as follow:

go get -u github.com/iamseth/oracledb_exporter

The error details is:

# github.com/iamseth/oracledb_exporter/vendor/github.com/mattn/go-oci8
/usr/local/golang/src/github.com/iamseth/oracledb_exporter/vendor/github.com/mattn/
go-oci8/oci8.go:4:17: fatal error: oci.h: No such file or directory
 #include <oci.h>
                 ^
compilation terminated.

And my go env is:

go version go1.6 linux/amd64

Please add FRA limit and used

Not really an issue but more a feature request with something already implemented but not working.
patch.txt

In short: it would be nice to have space_limit and space_used information of a FRA of an oracle db.

The query you see in the patch is working from sqlplus, but if i compile and launch oracledb_exporter i get

ERRO[0000] Error scraping for FRA space: OCI_SUCCESS_WITH_INFO source=main.go:

which is kind of odd and i don't know how to debug it.
It would be nice to have FRA information in the exporter, if you find a way to include it in the code it would be awesome

What is the expected form of the DATA_SOURCE_NAME string?

Hi,
I defined the environment DATA_SOURCE_NAME with username/[email protected]:1521/xe,and run it in container, but I got error like this:
level=error msg="Error pinging oracle: can't OCIEnvCreate" source="main.go:136"
I guess the DATA_SOURCE_NAME was not in correct form, could you please correct me?

I can connect to my database with the following tns description string:
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.0.228)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SID = xe)) )

Tablespace metrics not working

I'm not getting any tablespace metrics from my oracle instance. After doing some debugging, I found that it's because the query breaks when dfs.bytes is null. The query works just fine as is in SQL Developer and other tools, but when run in the exporter I get an OCI_SUCCESS_WITH_INFO and an empty row set.

Coalescing the value of dfs.bytes with 0 fixed the problem for me...pull request to follow.

correct execution steps for /path/to/binary

Hi all,
Under Running section, we can see the steps, however looks that not the complete instruction for the execution of the exporter.

$ /path/to/binary -l log.level error -l web.listen-address 9161
-bash: /path/to/binary: No such file or directory
$

can someone help me what is "/path/to/binary" path in this context?

Feature Request

Could you provide the feature to customize exporter listening port on Docker container version?

DATA_SOURCE_NAME environment variable

@iamseth , in the code there is a reliance on DATA_SOURCE_NAME environment variable:

export DATA_SOURCE_NAME=system/oracle@myhost

Is there a specific reason to do that? What if we pass dsn via flags?

diff --git a/main.go b/main.go
index 5e96929..b7e3636 100644
--- a/main.go
+++ b/main.go
@@ -4,7 +4,6 @@ import (
        "database/sql"
        "flag"
        "net/http"
-       "os"
        "strings"
        "time"

@@ -407,9 +406,10 @@ func cleanName(s string) string {
 }

 func main() {
+    var dsn string
+    flag.StringVar(&dsn, "dsn", "system/oracle@localhost", "data source name")
        flag.Parse()
        log.Infoln("Starting oracledb_exporter " + Version)
-       dsn := os.Getenv("DATA_SOURCE_NAME")
        exporter := NewExporter(dsn)
        prometheus.MustRegister(exporter)
        http.Handle(*metricPath, prometheus.Handler())

Then,

$ dist/oracledb_exporter.linux-amd64 -h
Usage of dist/oracledb_exporter.linux-amd64:
  -dsn string
    	data source name (default "system/oracle@localhost")
  -log.format value
    	If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.
  -log.level value
    	Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9161")
  -web.telemetry-path string
    	Path under which to expose metrics. (default "/metrics")

I follow the readme doc, but the metric turns out wrong

docker run --name oracle -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c
docker run -d --link=oracle -p 9161:9161 -e DATA_SOURCE_NAME=system/oracle@oracle/xe.oracle.docker iamseth/oracledb_exporter

But my metric shows as ::

HELP go_gc_duration_seconds A summary of the GC invocation durations.

TYPE go_gc_duration_seconds summary

go_gc_duration_seconds{quantile="0"} 3.42e-05
go_gc_duration_seconds{quantile="0.25"} 5.3e-05
go_gc_duration_seconds{quantile="0.5"} 6.57e-05
go_gc_duration_seconds{quantile="0.75"} 9.95e-05
go_gc_duration_seconds{quantile="1"} 0.0051045
go_gc_duration_seconds_sum 0.0189801
go_gc_duration_seconds_count 126

HELP go_goroutines Number of goroutines that currently exist.

TYPE go_goroutines gauge

go_goroutines 10

HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.

TYPE go_memstats_alloc_bytes gauge

go_memstats_alloc_bytes 779360

HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.

TYPE go_memstats_alloc_bytes_total counter

go_memstats_alloc_bytes_total 9.916064e+06

HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.

TYPE go_memstats_buck_hash_sys_bytes gauge

go_memstats_buck_hash_sys_bytes 1.443744e+06

HELP go_memstats_frees_total Total number of frees.

TYPE go_memstats_frees_total counter

go_memstats_frees_total 13945

HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.

TYPE go_memstats_gc_sys_bytes gauge

go_memstats_gc_sys_bytes 405504

HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.

TYPE go_memstats_heap_alloc_bytes gauge

go_memstats_heap_alloc_bytes 779360

HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.

TYPE go_memstats_heap_idle_bytes gauge

go_memstats_heap_idle_bytes 4.530176e+06

HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.

TYPE go_memstats_heap_inuse_bytes gauge

go_memstats_heap_inuse_bytes 1.400832e+06

HELP go_memstats_heap_objects Number of allocated objects.

TYPE go_memstats_heap_objects gauge

go_memstats_heap_objects 5175

HELP go_memstats_heap_released_bytes_total Total number of heap bytes released to OS.

TYPE go_memstats_heap_released_bytes_total counter

go_memstats_heap_released_bytes_total 4.530176e+06

HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.

TYPE go_memstats_heap_sys_bytes gauge

go_memstats_heap_sys_bytes 5.931008e+06

HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.

TYPE go_memstats_last_gc_time_seconds gauge

go_memstats_last_gc_time_seconds 1.5119417177522001e+09

HELP go_memstats_lookups_total Total number of pointer lookups.

TYPE go_memstats_lookups_total counter

go_memstats_lookups_total 100

HELP go_memstats_mallocs_total Total number of mallocs.

TYPE go_memstats_mallocs_total counter

go_memstats_mallocs_total 19120

HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.

TYPE go_memstats_mcache_inuse_bytes gauge

go_memstats_mcache_inuse_bytes 3472

HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.

TYPE go_memstats_mcache_sys_bytes gauge

go_memstats_mcache_sys_bytes 16384

HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.

TYPE go_memstats_mspan_inuse_bytes gauge

go_memstats_mspan_inuse_bytes 20976

HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.

TYPE go_memstats_mspan_sys_bytes gauge

go_memstats_mspan_sys_bytes 32768

HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.

TYPE go_memstats_next_gc_bytes gauge

go_memstats_next_gc_bytes 4.194304e+06

HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.

TYPE go_memstats_other_sys_bytes gauge

go_memstats_other_sys_bytes 794968

HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.

TYPE go_memstats_stack_inuse_bytes gauge

go_memstats_stack_inuse_bytes 360448

HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.

TYPE go_memstats_stack_sys_bytes gauge

go_memstats_stack_sys_bytes 360448

HELP go_memstats_sys_bytes Number of bytes obtained by system. Sum of all system allocations.

TYPE go_memstats_sys_bytes gauge

go_memstats_sys_bytes 8.984824e+06

HELP http_request_duration_microseconds The HTTP request latencies in microseconds.

TYPE http_request_duration_microseconds summary

http_request_duration_microseconds{handler="prometheus",quantile="0.5"} 2989.7
http_request_duration_microseconds{handler="prometheus",quantile="0.9"} 2989.7
http_request_duration_microseconds{handler="prometheus",quantile="0.99"} 2989.7
http_request_duration_microseconds_sum{handler="prometheus"} 50758.7
http_request_duration_microseconds_count{handler="prometheus"} 10

HELP http_request_size_bytes The HTTP request sizes in bytes.

TYPE http_request_size_bytes summary

http_request_size_bytes{handler="prometheus",quantile="0.5"} 446
http_request_size_bytes{handler="prometheus",quantile="0.9"} 446
http_request_size_bytes{handler="prometheus",quantile="0.99"} 446
http_request_size_bytes_sum{handler="prometheus"} 4416
http_request_size_bytes_count{handler="prometheus"} 10

HELP http_requests_total Total number of HTTP requests made.

TYPE http_requests_total counter

http_requests_total{code="200",handler="prometheus",method="get"} 10

HELP http_response_size_bytes The HTTP response sizes in bytes.

TYPE http_response_size_bytes summary

http_response_size_bytes{handler="prometheus",quantile="0.5"} 1550
http_response_size_bytes{handler="prometheus",quantile="0.9"} 1550
http_response_size_bytes{handler="prometheus",quantile="0.99"} 1550
http_response_size_bytes_sum{handler="prometheus"} 15192
http_response_size_bytes_count{handler="prometheus"} 10

HELP oracledb_exporter_last_scrape_duration_seconds Duration of the last scrape of metrics from Oracle DB.

TYPE oracledb_exporter_last_scrape_duration_seconds gauge

oracledb_exporter_last_scrape_duration_seconds 0.0006298

HELP oracledb_exporter_last_scrape_error Whether the last scrape of metrics from Oracle DB resulted in an error (1 for error, 0 for success).

TYPE oracledb_exporter_last_scrape_error gauge

oracledb_exporter_last_scrape_error 1

HELP oracledb_exporter_scrapes_total Total number of times Oracle DB was scraped for metrics.

TYPE oracledb_exporter_scrapes_total counter

oracledb_exporter_scrapes_total 12

HELP oracledb_up Whether the Oracle database server is up.

TYPE oracledb_up gauge

oracledb_up 0

HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.

TYPE process_cpu_seconds_total counter

process_cpu_seconds_total 0.33

HELP process_max_fds Maximum number of open file descriptors.

TYPE process_max_fds gauge

process_max_fds 1.048576e+06

HELP process_open_fds Number of open file descriptors.

TYPE process_open_fds gauge

process_open_fds 8

HELP process_resident_memory_bytes Resident memory size in bytes.

TYPE process_resident_memory_bytes gauge

process_resident_memory_bytes 2.3199744e+07

HELP process_start_time_seconds Start time of the process since unix epoch in seconds.

TYPE process_start_time_seconds gauge

process_start_time_seconds 1.51192666348e+09

HELP process_virtual_memory_bytes Virtual memory size in bytes.

TYPE process_virtual_memory_bytes gauge

process_virtual_memory_bytes 3.64326912e+08

Special character password unable to connect

Hi,

I having trouble using a password that contains special characters like % .

Error is always the same, even if I put the password in quotes or not:

Unable to connect to oracle:invalid URL escape "%m" source=main.go:179'

Just need some help to make the connection work.

Windows support?

I tried to build oracledb_exporter for windows, but this fails to build for me due to:

/home/mika/src/gopath/src/github.com/mattn/go-oci8/connector.go:14:10: undefined: OCI8Connector
/home/mika/src/gopath/src/github.com/mattn/go-oci8/connector.go:20:22: undefined: OCI8Connector
/home/mika/src/gopath/src/github.com/mattn/go-oci8/connector.go:21:9: undefined: OCI8Driver
[...]
/home/mika/src/gopath/src/github.com/mattn/go-oci8/connector.go:21:9: too many errors

I'm aware that the problem is lying within https://github.com/mattn/go-oci8, but I'm wondering if there are any plans to provide releases for Windows?

Thanks for providing oracledb_exporter!

Error scraping for <metric_name> : No metrics found while parsing

This seems to be the same issue as #33. I am running v0.2.0 of the exporter. It's connected to Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production. This is the error I get:

Mar 26 12:41:54 mgworker15.occ.liberty.edu oracledb_exporter-BBTSPRD[15598]: time="2019-03-26T12:41:54-04:00" level=error msg="Error scraping for wait_class:sessions : No metrics found while parsing" source="main.go:176"

The metric is defined as follows:

[[metric]]
context = "wait_class:sessions"
labels = [ "wait_class" ]
metricsdesc = { count = "Average number of sessions per wait_class per second in the past minute from gv$active_session_history." }
request = '''
select nvl(wait_class,'CPU + CPU Wait') as wait_class,
round(sum(1)/60, 2) count
from gv$active_session_history
where sample_time >= sysdate - (1/24/60)
group by wait_class
'''

I do not want to ignorezeroresult because this query should always have a value.

The query works fine when I run it as the user that the exporter is running as.

SQL> select nvl(wait_class,'CPU + CPU Wait') as wait_class,
round(sum(1)/60, 2) count
from gv$active_session_history
where sample_time >= sysdate - (1/24/60)
group by wait_class ;

WAIT_CLASS							      COUNT
---------------------------------------------------------------- ----------
CPU + CPU Wait							       1.35
Other									.05
Concurrency								.02
System I/O								.03
User I/O								.02

I have several other Oracle DBs that I am monitoring with this exporter and they're all using this exporter with this query without any problems.

Unable to scrape ORA-00942: table or view does not exist

Hello,

I'm running into this error below:
time="2019-02-14T14:25:45Z" level=error msg="Error scraping for activity: ORA-00942: table or view does not exist\n" source="main.go:144" time="2019-02-14T14:25:45Z" level=error msg="Error scraping for tablespace: ORA-00942: table or view does not exist\n" source="main.go:149" time="2019-02-14T14:25:45Z" level=error msg="Error scraping for wait_time: ORA-00942: table or view does not exist\n" source="main.go:154" time="2019-02-14T14:25:45Z" level=error msg="Error scraping for sessions: ORA-00942: table or view does not exist\n" source="main.go:159" time="2019-02-14T14:25:45Z" level=error msg="Error scraping for process: ORA-00942: table or view does not exist\n" source="main.go:164

Looks like a permission issue and maybe the $DATA_SOURCE_NAME connection string is problematic.

I tried the following:
export DATA_SOURCE_NAME="db_monitoring/password@localhost/service?"
export DATA_SOURCE_NAME="db_monitoring/password@localhost/service?as=sysdba"

Any suggestions?

ERRO[0000] Error scraping for backup : No metrics found while parsing source=main.go:188

I am using version 0.2.2 of the oracledb_exporter. My issue is similar to issue #50 but converting the value to an integer did not solve my problem.

[[metric]]
  context = "backup"
  metricsdesc = { last_backup_seconds = "Number of seconds since the last backup of a data file of an archivelog mode database."  }
  labels = [ "data_file" ]
  request = '''
  with cte (last_backup_seconds, data_file) as (
    select ((86400*(sysdate - coalesce(b.tijd, d.creation_time)))) as last_backup_seconds
    ,      d.name as data_file
    from   gv$datafile d
    ,      (select file#,max(tijd) tijd
           from  (select file#, max(completion_time) tijd
                  from   gv$backup_datafile
                  group  by file#
                  union
                  select file#, time                 tijd
                  from   gv$backup)
           group by file#)   b
    where  b.file# = d.file#
  )
  select CAST(last_backup_seconds as integer) as last_backup_seconds, data_file from cte
'''

results in:

bash-4.2$ /opt/prometheus/exporters/oracledb_exporter -log.level error -web.listen-address 192.168.40.13:9161 -default.metrics /etc/default/default-metrics.toml
ERRO[0000] Error scraping for backup : No metrics found while parsing  source=main.go:188

The cte part of the query is not really necessary but was added for readability while debugging this problem. Any idea what causes the error and do you have any tips how to debug this kind of problem in the oracledb_exporter?

When I run the query in Oracle I get:

LAST_BACKUP_SECONDS
-------------------
DATA_FILE
--------------------------------------------------------------------------------
	      69381
/opt/oracle/oradata/XE/pdbseed/sysaux01.dbf

	   28440138
/opt/oracle/oradata/XE/system01.dbf

	   28440115
/opt/oracle/oradata/XE/users01.dbf

In sqlplus I have to add set lines 600 to get a more readable result:

LAST_BACKUP_SECONDS DATA_FILE
------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	      69542 /opt/oracle/oradata/XE/pdbseed/sysaux01.dbf
	   28440299 /opt/oracle/oradata/XE/system01.dbf
	   28440276 /opt/oracle/oradata/XE/users01.dbf

I don't think the length of the data_file column is causing the error because I replaced that column with the file# column and I got the same error.

Not working after DB restart

Hi,

The exporter is not collecting metrics after DB restart. It's not creating new connection to database.
"Error pinging oracle: ORA-03114: not connected to ORACLE\n" source="main.go:168"

Thanks,

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.