01 Oct 2021 12:22 AM - last edited on 20 Aug 2024 02:15 PM by Michal_Gebacki
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?
Solved! Go to Solution.
01 Oct 2021 06:13 AM
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:
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.
01 Oct 2021 01:36 PM
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.
01 Oct 2021 02:24 PM
@RodrigoBiaggio you have actually two options here for sending.
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.
10 Jun 2022 07:07 AM
FYI: There is an officially supported plugin providing that functionality: Custom Database Queries.
20 Jun 2022 06:10 PM
How are database credentials stored and maintained with this plugin?
21 Jun 2022 07:02 PM
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}).
21 Jun 2022 07:19 PM
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.