cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Database Query Extension

Guys, please, I need some help on an extension. I need to create a plugin that executes a query against a MySQL database. Should I create an ActiveGate Extension or Oneagent extension? Does anyone have an example or any documentation that shows a model?

Dynatrace Professional
7 REPLIES 7

Julius_Loman
DynaMight Legend
DynaMight Legend

The answer is - it depends on the requirements. If it's for a single purpose, I'd consider writing a simple script that will execute queries using MySQL command line client and push the metrics using metric ingestion or events using API. This is much simpler than the writing extension.

If you still need to create an extension, keep in mind:

  • OneAgent extensions can only push data to process groups residing on the same host where they run. (so you must have Oneagent on the DB host).

  • ActiveGate extension creates new entities (custom devices). You can somehow also push data to existing entities based on metadata.

For samples see here in the docs and for inspiration, you can look into the code of the MySQL extension that is shipped with the OneAgent itself.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Julius, sorry, but just a question. To run the first option you mentioned, I would need the agent installed on the database servers, right? My question is how I would schedule this script execution and sending the metrics, which makes me wonder.

Dynatrace Professional

@RodrigoBiaggio  you have actually two options here for sending. 

  • You have OneAgent on the host from where you will send the metrics -> send them using local ingestion interface 
  • You don't have OneAgent on the host -> send them using API You will need to have an API token created in this case and typically you will want to set the dt.entity in the output.

Depending on your DB you can execute it remotely.
Regarding scheduling - use cron or systemd on Linux for example, Windows scheduler on windows. It's really up to you. You can also run a daemon in and process it in a loop.

 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Enrico_F
DynaMight Pro
DynaMight Pro

FYI: There is an officially supported plugin providing that functionality: Custom Database Queries.

How are database credentials stored and maintained with this plugin?

As with any custom extension that implements the Extensions SDK the instance config (including DB credentials in this case) can be managed either via the UI (via "endpoint config" in the custom extension settings) or programmatically via the config API (via GET/PUT/DELETE /api/config/v1/extensions/{id}/instances/{configurationId}).

Mike_L
Dynatrace Guru
Dynatrace Guru

They are stored encrypted in the Dynatrace database. It is then transferred in a secure way to the ActiveGate and never leave the ActiveGate’s memory.

Mike

Featured Posts