Set up common prometheus exporter configurations
- src: [email protected]:smartlogic/ansible-role-prometheus-exporters
name: prometheus-exporters
version: 2.0.0
Set up permission for the postgres_exporter user (by default) to have access to the necessary stats, update the password to something more secure
CREATE OR REPLACE FUNCTION __tmp_create_user() returns void as $$
BEGIN
IF NOT EXISTS (
SELECT -- SELECT list can stay empty for this
FROM pg_catalog.pg_user
WHERE usename = 'postgres_exporter') THEN
CREATE USER postgres_exporter;
END IF;
END;
$$ language plpgsql;
SELECT __tmp_create_user();
DROP FUNCTION __tmp_create_user();
ALTER USER postgres_exporter WITH PASSWORD '<set-a-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>;
GRANT CONNECT ON DATABASE postgres TO postgres_exporter;
These ports should be opened to the prometheus server based on the enabled exporters:
Exporter | Port |
---|---|
node | 9100 |
statsd | 9102 |
elasticsearch | 9114 |
blackbox | 9115 |
redis | 9121 |
postgres | 9187 |
node_exporter_version
- Which version of node exporter to downloadnode_exporter_checksum
- The checksum for the version of node exporternode_exporter_env_file
- A file, default to empty, can be in your playbook directory, that is the env file for the exporter, used to setNODE_EXPORTER_ARGS
for command line args or other env vars for node exporterredis_exporter_version
- Which version of redis_exporter to downloadredis_exporter_checksum
- The checksum for the version of redis_exporterredis_addr
- The address of the redis instance to monitor- Default:
redis://localhost:6379
- Default:
postgres_exporter_version
- Which version of postgres_exporter to downloadpostgres_exporter_checksum
- The checksum for the version of postgres_exporterpostgres_exporter_connection_host
- The host to connect to- Default:
/var/run/postgresql/
to use the default postgres socket
- Default:
postgres_exporter_connection_ssl_mode
- If to use ssl when connecting- Default:
disable
- because the default is socket connection
- Default:
postgres_exporter_connection_user
-- Default:
prometheus
- the connecting user (uses identity be default)
- Default:
postgres_exporter_data_source_uri
- use URI style with username and password ommited, used in place of the previous optionspostgres_exporter_data_source_user
- use with URI style to specify the userpostgres_exporter_data_source_pass
- use with URI style to specify the passwordblackbox_exporter_version
- Which version of blackbox_exporter to downloadblackbox_exporter_checksum
- The checksum for the version of blackbox_exporterstatsd_exporter_version
- Which version of statsd_exporter to downloadstatsd_exporter_checksum
- The checksum for the version of statsd_exporterstatsd_mapping_file
- The file to use for statsd mapping to prometheus metrics- Default: an empty mappings file
elasticsearch_exporter_version
- Which version of elasticsearch_exporter to downloadelasticsearch_exporter_checksum
- The checksum for the version of elasticsearch_exporterelasticsearch_exporter_listen_addr
- What interface and port to listen on, defaults to:9114
elasticsearch_exporter_uri
- The URI of the ES node to connect to, should includeusername:password@
if necessary, default ishttp://localhost:9200
None
If using the statsd_exporter action:
statsd_mapping_file: "{{ playbook_dir }}/files/statsd_mapping.yml"
Node exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["node_exporter"] }
Redis exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["redis_exporter"] }
Postgres exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["postgres_exporter"] }
Blackbox exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["blackbox_exporter"] }
Statsd exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["statsd_exporter"] }
Elasticsearch exporter only:
- hosts: servers
roles:
- { role: prometheus-exporters, actions: ["elasticsearch_exporter"] }
MIT
SmartLogic. https://smartlogic.io