Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle db input plugin #8568

Closed
wants to merge 5 commits into from
Closed

Oracle db input plugin #8568

wants to merge 5 commits into from

Conversation

unflag
Copy link
Contributor

@unflag unflag commented Dec 15, 2020

This plugin runs queries on Oracle DB and creates metrics from received data. It has abilities to control which columns would be tags/fields, to switch schema and to set query execution timeout. Logging is handy and can be really helpful when multiple plugin instances run on different databases and executes a lot of queries. It uses godror driver, so free Oracle Client libraries are required at run time. Tests could be run without it, because they use go-sqlmock package. I already use it several month in production and now hope it ready to be helpful to someone else.

Also closes #831

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@sjwang90
Copy link
Contributor

Besides being just OracleDB focused, can you state the discrepancies between your PR and the GenericSQL Plugin PR #2785?

@unflag
Copy link
Contributor Author

unflag commented Dec 16, 2020

Besides being just OracleDB focused, can you state the discrepancies between your PR and the GenericSQL Plugin PR #2785?

Sure.
First of all, this plugin doesn't have to be specifically compiled to support Oracle, it just uses external oracle libs at run time which makes it easier to use.

It gathers database metadata and place it in tags automatically, so it makes configuration less verbose and error prone, also metadata contains more data(because it OracleDB focused) compared to GenericSQL.

It supports per-query execution timeout, which can be helpful if some query starts being slow and takes all plugin interval time. From monitoring and alerting side it much more easy to investigate, when only one or two metrics lost instead of loosing all data and trying to understand why so many alerts rang.

And, as I can see in GenericSQL's code, it doesn't consider that Oracle can provide NUMBER data type, which is internally varchar and can store numbers which not fit in 2^64. In Go such values would have string type. There is not much we can do if we get too large numbers, of course, but I tried to save as much precision as possible by parsing string and using float64, int64 and uint64 types. GenericSQL, if I looked properly, would store such values as strings and they may be impossible to use with some outputs which doesn't accept fields with string values like opentsdb. Or to use them in math expressions. I hadn't enough time to test it or to look into the code more attentively, so I may be incorrect - please, point me to it.

@unflag
Copy link
Contributor Author

unflag commented Dec 17, 2020

As far as I can see there is some cross compilation issue with 386 arch because of CGO. Is there any way to fix it?
And windows builder complains that there is no gcc in path, is it true? I haven't any clue where to start...

@Hipska
Copy link
Contributor

Hipska commented Jan 14, 2021

If this plugin is only returning metrics coming from SQL queries, I would prefer to improve GenericSQL instead.

The Oracle plugin can be kept if this one also produces specific info of the Oracle DB, similar as the MySQL and PostgreSQL plugins.

@unflag
Copy link
Contributor Author

unflag commented Jan 16, 2021

Plugin generates metrics using sql queries only, but it also gathers some Oracle-specific runtime metadata to populate tags. It also has some Oracle-specific type conversion and use specific driver types. Unfortunately, I don't see a way how all of it can be added to existing GenericSQL logic.

@Hipska
Copy link
Contributor

Hipska commented Jan 20, 2021

The team will have a look on it and we will come back to you. Our preference is still towards the GenericSQL input plugin.

@Hipska Hipska added the plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins label Jan 21, 2021
@megastef
Copy link

A very interesting plugin. Many Oracle users would love it, including me. I was happy to see some news here after years of discussions. +1 to add it to telegraf.

@srebhan
Copy link
Member

srebhan commented Feb 1, 2021

Hey guys, sorry for being late to the party...

@unflag I do understand that you use certain Oracle-specific data. The whole problem with Oracle go-clients is that they all require CGO. You are using godror and in their README they are stating:

At least Go 1.13 is required! Cgo is required, so cross-compilation is hard, and you cannot set CGO_ENABLED=0!

While Go 1.13 is not a problem, the CGO requirement is a problem! Telegraf will not have CGO enabled AFAIK! This also hinders the GenericSQL plugin to support OracleDBs. :-(

One way to circumvent that issue might be to add this as external plugin. @ssoroka would this be possible, an external plugin with CGO enabled?

@ssoroka
Copy link
Contributor

ssoroka commented Feb 3, 2021

building as an external plugin with CGO is possible using inputs.execd. Unless we can find a native Go version of the driver, I think the external execd plugin is probably the best route.
check out the inputs.execd docs and the Telegraf shim docs which together allows a plugin to run as a separate binary.

Let me know if you have any questions or the status of non-cgo drivers changes

@ssoroka ssoroka closed this Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Oracle input plugin for database performance
6 participants