Skip to content

Commit

Permalink
simplified logic for grafana agent configuration templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ElineMaaikedeWeerd committed Jan 11, 2024
1 parent 124fdf1 commit d947926
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 60 deletions.
44 changes: 22 additions & 22 deletions roles/o11y_agent/templates/agent-deb.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ metrics:
host: {{ ansible_hostname }}
{% if group_names|intersect(['maas_region_controller', 'maas_rack_controller']) %}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
{% endif %}
remote_write:
- url: {{o11y_prometheus_url}}
Expand Down Expand Up @@ -61,8 +61,8 @@ logs:
labels:
job: "maas-audit"
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
maas_module: "audit"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
Expand All @@ -84,8 +84,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-console"

{% if 'maas_rack_controller' in group_names %}
Expand All @@ -95,8 +95,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-dhcpd"
{% endif %}

Expand All @@ -106,8 +106,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-metadata"

- job_name: maas-named
Expand All @@ -116,8 +116,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-named"

- job_name: maas-ntpd
Expand All @@ -126,8 +126,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-ntpd"

- job_name: maas-proxy
Expand All @@ -136,8 +136,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-proxy"

- job_name: maas-temporal
Expand All @@ -146,8 +146,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-temporal"

- job_name: maas-apiserver
Expand All @@ -156,8 +156,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-apiserver"

- job_name: maas-agent
Expand All @@ -166,8 +166,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-agent"
{% endif %}
{% if 'maas_postgres' in group_names %}
Expand Down
44 changes: 22 additions & 22 deletions roles/o11y_agent/templates/agent-snap.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ metrics:
host: {{ ansible_hostname }}
{% if group_names|intersect(['maas_region_controller', 'maas_rack_controller']) %}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
{% endif %}
remote_write:
- url: {{o11y_prometheus_url}}
Expand Down Expand Up @@ -61,8 +61,8 @@ logs:
labels:
job: "maas-audit"
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
maas_module: "audit"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
Expand All @@ -84,8 +84,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-console"

{% if 'maas_rack_controller' in group_names %}
Expand All @@ -95,8 +95,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-dhcpd"
{% endif %}

Expand All @@ -106,8 +106,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-metadata"

- job_name: maas-named
Expand All @@ -116,8 +116,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-named"

- job_name: maas-ntpd
Expand All @@ -126,8 +126,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-ntpd"

- job_name: maas-proxy
Expand All @@ -136,8 +136,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-proxy"

- job_name: maas-temporal
Expand All @@ -146,8 +146,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-temporal"

- job_name: maas-apiserver
Expand All @@ -156,8 +156,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-apiserver"

- job_name: maas-agent
Expand All @@ -166,8 +166,8 @@ logs:
labels:
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-agent"
{% endif %}
{% if 'maas_postgres' in group_names %}
Expand Down
32 changes: 16 additions & 16 deletions roles/o11y_agent/templates/grafana-agent.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ metrics:
host: {{ ansible_hostname }}
{% if group_names|intersect(['maas_region_controller', 'maas_rack_controller']) %}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
{% endif %}
remote_write:
- url: {{o11y_prometheus_url}}
Expand Down Expand Up @@ -61,8 +61,8 @@ logs:
labels:
job: "maas-audit"
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
maas_module: "audit"
relabel_configs:
- source_labels: ['__syslog_message_hostname']
Expand All @@ -84,8 +84,8 @@ logs:
__path__: {{ maas_log_dir }}/{regiond,rackd}.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-console"
pipeline_stages:
- regex:
Expand Down Expand Up @@ -115,8 +115,8 @@ logs:
__path__: {{ maas_log_dir }}/dhcpd*.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-dhcpd"
{% endif %}

Expand All @@ -126,8 +126,8 @@ logs:
__path__: {{ maas_log_dir }}/http/access.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-metadata"
pipeline_stages:
- regex:
Expand All @@ -147,8 +147,8 @@ logs:
__path__: {{ maas_log_dir }}/named.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-named"

- job_name: maas-ntpd
Expand All @@ -157,8 +157,8 @@ logs:
__path__: {{ maas_log_dir }}/chrony.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-ntpd"

- job_name: maas-proxy
Expand All @@ -167,8 +167,8 @@ logs:
__path__: {{ maas_log_dir }}/proxy.log
host: {{ ansible_hostname }}
maas_az: {{ maas_availability_zone | default('default') }}
maas_region: {{ 'True' if 'maas_region_controller' in group_names else 'False' }}
maas_rack: {{ 'True' if 'maas_rack_controller' in group_names else 'False' }}
maas_region: {{ 'maas_region_controller' in group_names }}
maas_rack: {{ 'maas_rack_controller' in group_names }}
job: "maas-proxy"
{% endif %}
{% if 'maas_postgres' in group_names %}
Expand Down

0 comments on commit d947926

Please sign in to comment.