diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-06-22 18:04:40 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-06-22 18:04:40 +0200 |
| commit | 1a7d06d83d41b343a48c181cb47c4c9974a5626a (patch) | |
| tree | 6df05c0a11d41a419d261bcd8a052de19172c2f6 /roles | |
| parent | ded892e34378c3675717384decebbf87e3f70039 (diff) | |
Refactor installing grafana dashboards using URL only
Refactor prometheus extra scraping jobs
Diffstat (limited to 'roles')
| -rw-r--r-- | roles/grafana/meta/argument_specs.yml | 14 | ||||
| -rw-r--r-- | roles/grafana/tasks/main.yml | 6 | ||||
| -rw-r--r-- | roles/prometheus/defaults/main.yml | 1 | ||||
| -rw-r--r-- | roles/prometheus/meta/argument_specs.yml | 5 | ||||
| -rw-r--r-- | roles/prometheus/templates/prometheus.yml.j2 | 8 |
5 files changed, 22 insertions, 12 deletions
diff --git a/roles/grafana/meta/argument_specs.yml b/roles/grafana/meta/argument_specs.yml index 5a38b97d..c9d53bb1 100644 --- a/roles/grafana/meta/argument_specs.yml +++ b/roles/grafana/meta/argument_specs.yml @@ -53,23 +53,19 @@ argument_specs: description: "FQDN for the grafana nginx vhost (e.g. 'monitor.home.arpa')." default: "monitor.home.arpa" grafana_dashboards: - description: "List of community dashboards to download and provision" + description: "List of dashboards to download and provision" type: "list" elements: "dict" default: [] options: - id: - description: "Grafana.com dashboard ID" - type: "int" - required: true - revision: - description: "Dashboard revision number" - type: "int" - required: true name: description: "Local name for the dashboard file" type: "str" required: true + url: + description: "URL to download the dashboard JSON from" + type: "str" + required: true datasource_mappings: description: "List of datasource variable mappings for the dashboard" type: "list" diff --git a/roles/grafana/tasks/main.yml b/roles/grafana/tasks/main.yml index f7b7d851..088d61c7 100644 --- a/roles/grafana/tasks/main.yml +++ b/roles/grafana/tasks/main.yml @@ -53,7 +53,7 @@ notify: "Restart grafana" no_log: true -- name: "Provision Grafana community dashboards" +- name: "Provision Grafana dashboards" notify: "Restart grafana" # grafana downloaded dashboards are being rewritten after successful download # this is to correct the datasource mapping in the downloaded files @@ -61,10 +61,10 @@ tags: - molecule-idempotence-notest block: - - name: "Download Grafana community dashboards" + - name: "Download Grafana dashboards" become: true ansible.builtin.get_url: - url: "https://grafana.com/api/dashboards/{{ item.id }}/revisions/{{ item.revision }}/download" + url: "{{ item.url }}" dest: "/etc/grafana/provisioning/dashboards/{{ item.name }}.json" owner: "grafana" group: "grafana" diff --git a/roles/prometheus/defaults/main.yml b/roles/prometheus/defaults/main.yml index cd91dee6..61c383ed 100644 --- a/roles/prometheus/defaults/main.yml +++ b/roles/prometheus/defaults/main.yml @@ -9,3 +9,4 @@ prometheus_targets: prometheus_node_exporter_targets: [] prometheus_hostname: "metrics.home.arpa" +prometheus_extra_scrape_configs: [] diff --git a/roles/prometheus/meta/argument_specs.yml b/roles/prometheus/meta/argument_specs.yml index 5f908119..11beae38 100644 --- a/roles/prometheus/meta/argument_specs.yml +++ b/roles/prometheus/meta/argument_specs.yml @@ -32,3 +32,8 @@ argument_specs: type: "str" description: "FQDN for the prometheus nginx vhost (e.g. 'metrics.home.arpa')." default: "metrics.home.arpa" + prometheus_extra_scrape_configs: + description: "Additional Prometheus scrape jobs" + type: "list" + elements: "dict" + default: [] diff --git a/roles/prometheus/templates/prometheus.yml.j2 b/roles/prometheus/templates/prometheus.yml.j2 index c43864ea..f7f2ae24 100644 --- a/roles/prometheus/templates/prometheus.yml.j2 +++ b/roles/prometheus/templates/prometheus.yml.j2 @@ -15,3 +15,11 @@ scrape_configs: - targets: {{ prometheus_node_exporter_targets | to_yaml }} scrape_interval: {{ prometheus_scrape_interval }} metrics_path: /metrics +{% for job in prometheus_extra_scrape_configs %} + + - job_name: '{{ job.name }}' + static_configs: + - targets: {{ job.targets | to_yaml }} + scrape_interval: {{ job.scrape_interval | default(prometheus_scrape_interval) }} + metrics_path: {{ job.metrics_path | default('/metrics') }} +{% endfor %} |
