Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Prometheus Exporter Examples

Once the deployed prometheus-exporter operator is up and running and watching for any PrometheusExporter resource type, you can setup any prometheus exporter following the next examples:

  1. Memcached
  2. Redis
  3. MySQL
  4. PostgreSQL
  5. Sphinx
  6. Elasticsearch
  7. AWS CloudWatch
  8. Probe
  9. Sendgrid

Memcached

Deploy example

$ make memcached-create
  • Once tested, delete created objects:
$ make memcached-delete

Redis

Deploy example

$ make redis-create
  • Once tested, delete created objects:
$ make redis-delete

MySQL

CR needed extra object

  • The Secret should have been previously created as the operator expects it:

Permission requirements

  • In addition, a database user with specific grants is needed (this is just an example, go to the official doc for the latest information):
CREATE USER 'exporter'@'%' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'%';

NOTE
It is recommended to set a max connection limit for the user to avoid overloading the server with monitoring scrapes under heavy load.

Deploy example

$ make mysql-create
  • Once tested, delete created objects:
$ make mysql-delete

PostgreSQL

CR needed extra object

  • The Secret should have been previously created as the operator expects it:

Permission requirements

  • In addition, a database user with specific grants is needed*(this is just an example, go to official doc for latest information)*. To be able to collect metrics from pg_stat_activity and pg_stat_replication as non-superuser you have to create views as a superuser, and assign permissions separately to those. In PostgreSQL, views run with the permissions of the user that created them so they can act as security barriers (this is just an example, go to official doc for latest information):
CREATE USER postgres_exporter PASSWORD 'password';
ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog;

-- If deploying as non-superuser (for example in AWS RDS), uncomment the GRANT
-- line below and replace <MASTER_USER> with your root user.
-- GRANT postgres_exporter TO <MASTER_USER>
CREATE SCHEMA postgres_exporter AUTHORIZATION postgres_exporter;

CREATE VIEW postgres_exporter.pg_stat_activity
AS
  SELECT * from pg_catalog.pg_stat_activity;

GRANT SELECT ON postgres_exporter.pg_stat_activity TO postgres_exporter;

CREATE VIEW postgres_exporter.pg_stat_replication AS
  SELECT * from pg_catalog.pg_stat_replication;

GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;

NOTE
Remember to use postgres database name in the connection string:

DATA_SOURCE_NAME=postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable

Deploy example

$ make postgresql-create
  • Once tested, delete created objects:
$ make postgresql-delete

Sphinx

Deploy example

  • Make sure you have a Sphinx instance available, and dbHost/dbPort are correctly set on CR example file
  • Create sphinx-exporter example (example-CR):
$ make sphinx-create
  • Once tested, delete created objects:
$ make sphinx-delete

Manticore

Deploy example

  • Make sure you have a Manticore instance available, and dbHost/dbPort are correctly set on CR example file
  • Create manticore-exporter example (example-CR):
$ make manticore-create
  • Once tested, delete created objects:
$ make manticore-delete

Elasticsearch

Deploy example

  • Make sure you have an Elasticsearch cluster available and that dbHost/dbPort are correctly set on CR example file
  • Create elasticsearch-exporter example (example-CR):
$ make elasticsearch-create
  • Once tested, delete created objects:
$ make elasticsearch-delete

AWS CloudWatch

NOTE
The metrics from some services like AWSClientVPN are reported to AWS CloudWatch every 5 minutes (instead of default 1 minute), because they are not critical services like databases (RDS/EC) where details are more important. So on thoses cases, scrapping AWS Cloudwatch metrics every 1 minute makes no sense, so it is better to specify the var period_seconds: 300 (instead of default period_seconds: 60) in the metric definition in the configmap. In addition, for those cases reporting metrics every 5 minutes, empty spaces (null values) could appear empty in the prometheus time series database, so in order to configure alerts, you can use queries like max_over_time(aws_clientvpn_crl_days_to_expiry_average[10m]) < 2, which takes max value within last 10 minutes, so we guarantee there is always a value that can fire an alert that won't disappear from time to time although alert might not be really recovered.

CR needed extra objects

  • The Secret/ConfigMap should have been previously created as the operator expects them:
    • cw-secret-example (Remember to set the object name on the CR field awsCredentialsSecretName)
    • cw-configmap-example (Remember to set the object name on the CR field configurationConfigmapName)

Permission requirements

  • In addition, the created IAM user requires some specific IAM permissions:
    • cloudwatch:ListMetrics
    • cloudwatch:GetMetricStatistics
    • tag:GetResources

Deploy example

$ make cloudwatch-create
  • Once tested, delete the created objects:
$ make cloudwatch-delete

Probe

CR needed extra object

  • The ConfigMap should have been previously created as the operator expects it:
  • The optional Secret (replacing previous ConfigMap) should have been previously created as the operator expects it (in case config includes sensitive data and so you prefer to use a Secret
    • probe-secret-example (Remember to set the object name on the CR field configurationSecretName replacing previous configurationConfigmapName)

NOTE
To deploy a probe exporter (blackbox exporter) it is just needed the configmap (or secret) with blackbox modules configuration, and a single PrometheusExporter custom resource of type probe. But then, in order to be able to scrape different targets, you need to deploy for every endpoint that you want to monitor, a prometheus Probe resource with the prober.url pointing to the deployed probe exporter service prometheus-exporter-probe-${CR_NAME}.${NAMESPACE}.svc:9115, and then configure the specific module and target.

Target Probe extra objects

  • probe-target-probe-example (Remember to set the prober.url pointing to the deployed probe exporter service prometheus-exporter-probe-${CR_NAME}.${NAMESPACE}.svc:9115)

Deploy example

$ make probe-create
  • Once tested, delete the created objects:
$ make probe-delete

Sendgrid

CR needed extra object

  • The Secret should have been previously created as the operator expects it:

Deploy example

$ make sendgrid-create
  • Once tested, delete the created objects:
$ make sendgrid-delete