# Error creating connection to Oracle

**URL:** <https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [December 8, 2020, 11:32am UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980 "2020-12-08T11:32:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 8, 2020, 11:32am UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/1 "2020-12-08T11:32:59Z")

</div>

Hi  
I'm having a lot of problems getting the metricbeat connect to my Oracle database!

What ever I'm trying to put in my YML-file I always end up with this error:

Error fetching data for metricset oracle.tablespace: error creating connection to Oracle

My YML-file is like this:

```
metricbeat.modules:
- module: oracle
  metricsets: ["tablespace", "performance"]
  enabled: true
  period: 10s
  hosts: ["oracle://10.48.179.59:1521/(service name)?sysdba=1"]  
  username: "system"
  password: " ****"

```

Any suggestions?

Best regards  
Jens Christiansen

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 8, 2020, 2:09pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/2 "2020-12-08T14:09:17Z")

</div>

Hi @jenssc,

I assume you made sure the requirements mentioned in [https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-oracle.html#\_requirements](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-oracle.html#_requirements) are fulfilled?

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 8, 2020, 10:39pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/3 "2020-12-08T22:39:30Z")

</div>

Hi @weltenwort  
Everything should be installed according to the requirements. However, we currently use version 19.3 of the Oracle client!  
I'm running everything on a Windows host so I'm not sure if LD\_LIBRARY\_PATH is required or only the standard PATH in Windows, but I've tried both without luck.

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 9, 2020, 4:40pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/4 "2020-12-09T16:40:51Z")

</div>

Is there anything else in the log after "error creating connection to Oracle"? Could you maybe share the full log output?

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 10:08am UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/5 "2020-12-14T10:08:41Z")

</div>

Hi @weltenwort

Here is the result of t a test modules (I've changed the username/password):

```
oracle...
  tablespace...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://username%3Apassword%40ncps-t-db01.prod.sitad.dk%3A1521:SECRET-nKaKvQ2XRYo=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error
  performance...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://username%3Apassword%40ncps-t-db01.prod.sitad.dk%3A1521:SECRET-nKaKvQ2XRYo=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error
oracle...
  tablespace...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://user%3Apass%400.0.0.0%3A1521:SECRET-GIRSvgyNems=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error
  performance...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://user%3Apass%400.0.0.0%3A1521:SECRET-GIRSvgyNems=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error

```

Hope you have a great idea to a solution 🙂

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 10:45am UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/6 "2020-12-14T10:45:34Z")

</div>

I'm not at all knowledgeable about Oracle, so I can only try to make sure it's not a metricbeat problem. The `ORA-12560` seems to be a very generic transport error, but at least it seems to be able to pick up the shared library. Can you connect to the DB using a different client from the machine in question using the same credentials?

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 11:02am UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/7 "2020-12-14T11:02:33Z")

</div>

Yes - that is working great.  
But it seems that the service name is lost when the metricbeat is trying to connect. We can't use SID and my host configuration is like this (without username/password):

@ncps-t-db01.prod.sitad.dk:1521/ncpswmx.prod.sitad.dk

But that is no where to be found in the output:

@ncps-t-db01.prod.sitad.dk:1521:SECRET-nKaKvQ2XRYo=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone=

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 12:46pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/8 "2020-12-14T12:46:41Z")

</div>

The examples in the metricbeat [Oracle module docs](https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-oracle.html#_example_configuration_45) show the connection string in `hosts` as `user:pass@host:port/db` without the `oracle://` prefix and with the username and password being embedded in the string. Did you try that?

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 12:48pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/9 "2020-12-14T12:48:07Z")

</div>

@Mario_Castro any idea what else we could do to track down this connection problem?

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 12:49pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/10 "2020-12-14T12:49:03Z")

</div>

I don't have oracle:// in front - that is added by the metricbeat.

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 12:50pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/11 "2020-12-14T12:50:16Z")

</div>

Ok, just checking, because your yaml config snippet in the original post contains it. 👍

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 12:51pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/12 "2020-12-14T12:51:20Z")

</div>

actually... putting the oracle:// in front fixes two of the error

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 12:52pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/13 "2020-12-14T12:52:24Z")

</div>

but I still gets these two errors:

```
oracle...
  tablespace...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://user%3Apass%400.0.0.0%3A1521:SECRET-GIRSvgyNems=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error
  performance...
    error... ERROR error creating connection to Oracle: error doing ping to database: params=oracle://user%3Apass%400.0.0.0%3A1521:SECRET-GIRSvgyNems=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone= extAuth=0: ORA-12560: TNS:protocol adapter error
```

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 12:52pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/14 "2020-12-14T12:52:47Z")

</div>

but now I get OK on table and performance!

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 12:57pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/15 "2020-12-14T12:57:07Z")

</div>

Weird, but at least an improvement. Looking at the metricbeat module code the string is just passed to the `ParseConnString()` function of the `godror` package, so maybe one of the other [connection string formats](https://godror.github.io/godror/doc/connection.html#-connection-strings) works, such as

```auto
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orclpdb1)))

```

?

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 12:59pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/16 "2020-12-14T12:59:38Z")

</div>

Exactly and that is actually working if I put the oracle:// in front.

However, why is the metricbeat doing this connection (which is the one failing):

`oracle://user:pass@0.0.0.0:1521:SECRET-GIRSvgyNems=@?connectionClass=GODROR&enableEvents=0&heterogeneousPool=0&poolIncrement=1&poolMaxSessions=1000&poolMinSessions=1&poolSessionMaxLifetime=1h0m0s&poolSessionTimeout=5m0s&poolWaitTimeout=30s&prelim=0&standaloneConnection=0&sysasm=0&sysdba=0&sysoper=0&timezone=`

I Don't have anything in my yml file indicating that the metricbeat should do a connection to 0.0.0.0 and I didn't change the username/password - it says user:pass in the log!

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [December 14, 2020, 1:02pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/17 "2020-12-14T13:02:11Z")

</div>

Do you possibly have a duplicate config file in `modules.d` that contains these incorrect params?

---

<div class="post-metadata">

**Author:** ![Mario\_Castro](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_castro/32/35107_2.png) [@Mario\_Castro](https://discuss.elastic.co/u/Mario_Castro)\
**Post date:** [December 14, 2020, 1:02pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/18 "2020-12-14T13:02:24Z")

</div>

Hi @jenssc 🙂

Your error is a bit weird, not sure if related to your specific oracle version or something in the oracle library. While I investigate a bit more, can you try to connect as `sysdba` but like `oracle://10.48.179.59:1521/(service name) AS SYSDBA` instead of `sysdba=1`. It's a long shot but maybe it's related, I think the error comes from Oracle complaining about an invalid SID

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 1:05pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/19 "2020-12-14T13:05:28Z")

</div>

let me try 🙂

---

<div class="post-metadata">

**Author:** ![jenssc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenssc/32/77950_2.png) [@jenssc](https://discuss.elastic.co/u/jenssc)\
**Post date:** [December 14, 2020, 1:13pm UTC](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980/20 "2020-12-14T13:13:32Z")

</div>

wauv you are good @weltenwort 🙂

I've been adding my settings in the metricbeat.yml file but I see that you have the settings in the modules.d files and 0.0.0.0 is the default value of that file.

[Next page](https://discuss.elastic.co/t/error-creating-connection-to-oracle/257980.md?page=2)
