Integrating Azure Monitor Metrics to Prometheus Time-Series Database With Azure Exporter
In this article, see how to integrate Azure monitor metrics to Prometheus time-series database with Azure exporter.
Join the DZone community and get the full member experience.Join For Free
The use case is to get the Azure resource metrics and to save it in local DB. In this case, as this is time-series data, we can expect large chunks of data per minute. For time series storage, the first option that came to mind is Prometheus.
Below are the steps we have to do to get Azure resource metrics to our Prometheus database.
- Installation of Prometheus
- Setting up Azure metrics exporter
- Configuring .yaml files for Prometheus/Azure exporter
In a nutshell, we have to generate an endpoint where it lists all the resource metrics like in the below format. Then we have to configure the endpoint in the Prometheus configuration yaml file.
Note: In LINUX based system we are doing this process.
Installation of Prometheus:
Installation of Azure Metrics Exporter:
Azure exporter requires GO Lang to be installed. So we need to install GO in the system.
Installation of GO.
Installing Azure Metric Exporter Plugin:
We are using the exporter from https://github.com/RobustPerception/azure_metrics_exporter
go get -u github.com/RobustPerception/azure_metrics_exporter
In the bin folder of azure go/bin: create below file azure.yml.
Note: We have to create an application in the Azure portal before doing this. After creating the application, we will get a client secret and client id. We can configure YAML to get a given resource group of resources or a given resource type metrics to fetch.
Start the Exporter service after the above configuration,
It will enable metrics endpoint at 9276 port. To check, navigate to
You will get a list of metrics with values and time stamp in the above URL response.
Now the above endpoint to be sourced to Prometheus DB. This can be done in the Prometheus configuration file. Create a new yaml file in the Prometheus installation directory as shown below.
We have given scrape interval as 1m, as we are getting metrics in 1-minute scrape interval.
Start the Prometheus server with the new configuration file created above.
/home/user/prometheus-2.13.0.linux-amd64# ./prometheus --config.file=prometheus-azure-metric.yml --web.listen-address=:9011
Now the proemtheous running at port number 9011. Navigate to
http://localhost:9011 and check the metrics.
As we discussed earlier, all Prometheus needed is one endpoint where all the metrics will be available. That endpoint is localhost:9276, which we created using Azure exporter.
By default, Prometheus retains data till 15 days, which means it can hold history data for the last 15 days only. To make that customized, we have to provide an extra flag while starting Prometheus.
--storage.tsdb.retention=365d — you can provide any number of days.
Further extensions, we can also integrate the Prometheus with Grafana. Grafana is a metric dashboard interface. We can add Prometheus as a source to Grafana and see the metrics in Grafana.
Opinions expressed by DZone contributors are their own.