Browse Source

Added prom-sql target

pull/11/head
Egon Rijpkema 3 years ago
parent
commit
44b25a9d8a
  1. 25
      roles/prom_server/templates/etc/alerting.rules
  2. 7
      roles/prom_server/templates/etc/prometheus.yml
  3. 2
      roles/prom_sql/tasks/main.yml
  4. 7
      roles/prom_sql/templates/prom-sql.service
  5. 6
      roles/prom_sql/templates/queries.yml
  6. 2
      roles/prom_sql/templates/sql-agent.service

25
roles/prom_server/templates/etc/alerting.rules

@ -137,6 +137,31 @@ groups: @@ -137,6 +137,31 @@ groups:
annotations:
description: '{{ $labels.instance }}: Has high memory usage'
summary: '{{ $labels.instance }} has high memory usage.'
- alert: assoc_usage_day records lost
expr: query_result_assoc_usage_day{instance="127.0.0.1:9096",job="prometheus-sql"} < max(query_result_assoc_usage_day{instance="127.0.0.1:9096",job="prometheus-sql"})
for: 5m
labels:
severity: page
annotations:
description: 'assoc_usage_day table rows lost'
summary: 'assoc_usage_day table rows lost'
- alert: assoc_usage_hour records lost
expr: query_result_assoc_usage_hour{instance="127.0.0.1:9096",job="prometheus-sql"} < max(query_result_assoc_usage_hour{instance="127.0.0.1:9096",job="prometheus-sql"})
for: 5m
labels:
severity: page
annotations:
description: 'assoc_usage_hour table rows lost'
summary: 'assoc_usage_hour table rows lost'
- alert: assoc_usage_month records lost
expr: query_result_assoc_usage_month{instance="127.0.0.1:9096",job="prometheus-sql"} < max(query_result_assoc_usage_month{instance="127.0.0.1:9096",job="prometheus-sql"})
for: 5m
labels:
severity: page
annotations:
description: 'assoc_usage_month table rows lost'
summary: 'assoc_usage_month table rows lost'
# - alert: TestAlert
# expr: probe_success{instance="195.169.22.220:11211",job="blackbox"} == 0

7
roles/prom_server/templates/etc/prometheus.yml

@ -98,6 +98,13 @@ scrape_configs: @@ -98,6 +98,13 @@ scrape_configs:
- targets:
- pg-node001:8080
# Scrape the prometheus-sql service
- job_name: 'prometheus-sql'
scrape_interval: 60s
static_configs:
- targets:
- 127.0.0.1:9096
rule_files:
- '/etc/prometheus/alerting.rules'

2
roles/prom_sql/tasks/main.yml

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
mode: 0755
- name: Copy the settings file.
copy:
template:
src: templates/queries.yml
dest: /usr/local/prom-sql
mode: 0600

7
roles/prom_sql/templates/prom-sql.service

@ -9,11 +9,10 @@ Restart=always @@ -9,11 +9,10 @@ Restart=always
ExecStartPre=-/usr/bin/docker stop %n
ExecStartPre=-/usr/bin/docker rm %n
#Run daemon in the forground. systemd and docker do the daemonizing.
ExecStart=/usr/bin/docker run --rm --name %n \
-p 9096:8080 \
ExecStart=/usr/bin/docker run --rm --name %n --network host \
-v /usr/local/prom-sql/queries.yml:/queries.yml \
--link sql-agent.service:sqlagent \
dbhi/prometheus-sql
dbhi/prometheus-sql \
-service http://localhost:5000 -port 9096
[Install]
WantedBy=multi-user.target

6
roles/prom_sql/templates/queries.yml

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
host: gospel.service.rug.nl
port: 3306
user: slurmacc_pg
password: Go-kail3
password: "{{ slurm_storage_pass }}"
database: slurm_pg_accounting
sql: >
@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
host: gospel.service.rug.nl
port: 3306
user: slurmacc_pg
password: Go-kail3
password: "{{ slurm_storage_pass }}"
database: slurm_pg_accounting
sql: >
@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
host: gospel.service.rug.nl
port: 3306
user: slurmacc_pg
password: Go-kail3
password: "{{ slurm_storage_pass }}"
database: slurm_pg_accounting
sql: >

2
roles/prom_sql/templates/sql-agent.service

@ -9,7 +9,7 @@ Restart=always @@ -9,7 +9,7 @@ Restart=always
ExecStartPre=-/usr/bin/docker stop %n
ExecStartPre=-/usr/bin/docker rm %n
# Run daemon in the forground. systemd and docker do the daemonizing,
ExecStart=/usr/bin/docker run --rm --name %n dbhi/sql-agent
ExecStart=/usr/bin/docker run --rm --network host --name %n dbhi/sql-agent
[Install]

Loading…
Cancel
Save