Refine otel collector configuration variables
This commit is contained in:
parent
dba6f60e7a
commit
02ca9ea187
@ -3,32 +3,88 @@
|
|||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
group: web
|
group: web
|
||||||
|
otlp_endpoint: &otel_endpoint https://otel.svc.plus/api/default/
|
||||||
|
otlp_auth: &otel_auth "Basic cm9vdEBleGFtcGxlLmNvbTpRN01wRjZBTzZFelRjRjdJ"
|
||||||
|
otel_prometheus_node_static_configs: &otel_node_static_configs
|
||||||
|
- targets: ['172.31.2.33:9100']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: core
|
||||||
|
name: tky-proxy.svc.plus
|
||||||
|
iid: '172.31.2.33'
|
||||||
|
- targets: ['167.179.72.223:9100']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: global-homepage.svc.plus
|
||||||
|
iid: '167.179.72.223'
|
||||||
|
- targets: ['47.120.61.35:9100']
|
||||||
|
labels:
|
||||||
|
vendor: alicloud
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: cn-homepage.svc.plus
|
||||||
|
iid: '47.120.61.35'
|
||||||
|
otel_prometheus_process_static_configs: &otel_process_static_configs
|
||||||
|
- targets: ['172.31.2.33:9256']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: core
|
||||||
|
name: tky-proxy.svc.plus
|
||||||
|
iid: '172.31.2.33'
|
||||||
|
- targets: ['167.179.72.223:9256']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: global-homepage.svc.plus
|
||||||
|
iid: '167.179.72.223'
|
||||||
|
- targets: ['47.120.61.35:9256']
|
||||||
|
labels:
|
||||||
|
vendor: alicloud
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: cn-homepage.svc.plus
|
||||||
|
iid: '47.120.61.35'
|
||||||
exporters:
|
exporters:
|
||||||
endpoint: https://otel.svc.plus/api/default/
|
endpoint: *otel_endpoint
|
||||||
roles:
|
roles:
|
||||||
- roles/vhosts/common/
|
- roles/vhosts/common/
|
||||||
- roles/vhosts/node_exporter/
|
- roles/vhosts/node_exporter/
|
||||||
- roles/vhosts/process_exporter/
|
- roles/vhosts/process_exporter/
|
||||||
- roles/vhosts/otel-collector/
|
- roles/vhosts/otel-collector/
|
||||||
|
|
||||||
- name: setup otel exporters
|
- name: setup otel exporters
|
||||||
hosts: global-homepage.svc.plus
|
hosts: global-homepage.svc.plus
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
group: web
|
group: web
|
||||||
|
otlp_endpoint: *otel_endpoint
|
||||||
|
otlp_auth: *otel_auth
|
||||||
|
otel_prometheus_node_static_configs: *otel_node_static_configs
|
||||||
|
otel_prometheus_process_static_configs: *otel_process_static_configs
|
||||||
exporters:
|
exporters:
|
||||||
endpoint: https://otel.svc.plus/api/default/
|
endpoint: *otel_endpoint
|
||||||
roles:
|
roles:
|
||||||
- roles/vhosts/common/
|
- roles/vhosts/common/
|
||||||
- roles/vhosts/node_exporter/
|
- roles/vhosts/node_exporter/
|
||||||
- roles/vhosts/process_exporter/
|
- roles/vhosts/process_exporter/
|
||||||
- roles/vhosts/otel-collector/
|
- roles/vhosts/otel-collector/
|
||||||
|
|
||||||
- name: setup otel exporters
|
- name: setup otel exporters
|
||||||
hosts: otel.svc.plus
|
hosts: otel.svc.plus
|
||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
group: web
|
group: web
|
||||||
|
otlp_endpoint: *otel_endpoint
|
||||||
|
otlp_auth: *otel_auth
|
||||||
|
otel_prometheus_node_static_configs: *otel_node_static_configs
|
||||||
|
otel_prometheus_process_static_configs: *otel_process_static_configs
|
||||||
exporters:
|
exporters:
|
||||||
endpoint: https://otel.svc.plus/api/default/
|
endpoint: *otel_endpoint
|
||||||
roles:
|
roles:
|
||||||
- roles/vhosts/node_exporter/
|
- roles/vhosts/node_exporter/
|
||||||
- roles/vhosts/process_exporter/
|
- roles/vhosts/process_exporter/
|
||||||
|
|||||||
@ -3,6 +3,52 @@
|
|||||||
become: true
|
become: true
|
||||||
vars:
|
vars:
|
||||||
group: web
|
group: web
|
||||||
|
otlp_endpoint: https://otel.svc.plus/api/default/
|
||||||
|
otlp_auth: "Basic cm9vdEBleGFtcGxlLmNvbTpRN01wRjZBTzZFelRjRjdJ"
|
||||||
|
otel_prometheus_node_static_configs:
|
||||||
|
- targets: ['172.31.2.33:9100']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: core
|
||||||
|
name: tky-proxy.svc.plus
|
||||||
|
iid: '172.31.2.33'
|
||||||
|
- targets: ['167.179.72.223:9100']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: global-homepage.svc.plus
|
||||||
|
iid: '167.179.72.223'
|
||||||
|
- targets: ['47.120.61.35:9100']
|
||||||
|
labels:
|
||||||
|
vendor: alicloud
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: cn-homepage.svc.plus
|
||||||
|
iid: '47.120.61.35'
|
||||||
|
otel_prometheus_process_static_configs:
|
||||||
|
- targets: ['172.31.2.33:9256']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: core
|
||||||
|
name: tky-proxy.svc.plus
|
||||||
|
iid: '172.31.2.33'
|
||||||
|
- targets: ['167.179.72.223:9256']
|
||||||
|
labels:
|
||||||
|
vendor: aws
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: global-homepage.svc.plus
|
||||||
|
iid: '167.179.72.223'
|
||||||
|
- targets: ['47.120.61.35:9256']
|
||||||
|
labels:
|
||||||
|
vendor: alicloud
|
||||||
|
account: prod
|
||||||
|
group: web-system
|
||||||
|
name: cn-homepage.svc.plus
|
||||||
|
iid: '47.120.61.35'
|
||||||
exporters:
|
exporters:
|
||||||
endpoint: https://otel.svc.plus/api/default/
|
endpoint: https://otel.svc.plus/api/default/
|
||||||
roles:
|
roles:
|
||||||
|
|||||||
@ -78,6 +78,15 @@
|
|||||||
# - inventory_hostname in groups[group]
|
# - inventory_hostname in groups[group]
|
||||||
# - ansible_os_family == 'Debian'
|
# - ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
# === Configuration validation ===
|
||||||
|
- name: Ensure OpenObserve authorization is provided
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- otlp_auth is defined
|
||||||
|
- otlp_auth | string | trim | length > 0
|
||||||
|
fail_msg: otlp_auth must be defined and non-empty for otel collector deployment
|
||||||
|
when: inventory_hostname in groups[group]
|
||||||
|
|
||||||
- name: Deploy otel collector config
|
- name: Deploy otel collector config
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: otel-config.yaml
|
src: otel-config.yaml
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
{% set node_static_configs = otel_prometheus_node_static_configs | mandatory('otel_prometheus_node_static_configs must be provided') %}
|
||||||
|
{% set process_static_configs = otel_prometheus_process_static_configs | mandatory('otel_prometheus_process_static_configs must be provided') %}
|
||||||
|
|
||||||
receivers:
|
receivers:
|
||||||
prometheus:
|
prometheus:
|
||||||
config:
|
config:
|
||||||
@ -6,22 +9,22 @@ receivers:
|
|||||||
scrape_configs:
|
scrape_configs:
|
||||||
- job_name: 'node-exporter'
|
- job_name: 'node-exporter'
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9100']
|
{% for static_config in node_static_configs %}
|
||||||
|
- targets: {{ static_config.targets | to_json }}
|
||||||
labels:
|
labels:
|
||||||
vendor: '{{ otel_vendor | default("aws") }}'
|
{% for label_key, label_value in static_config.labels.items() %}
|
||||||
account: '{{ otel_account | default("prod") }}'
|
{{ label_key }}: '{{ label_value }}'
|
||||||
group: '{{ otel_group | default("core") }}'
|
{% endfor %}
|
||||||
name: '{{ otel_name | default(inventory_hostname) }}'
|
{% endfor %}
|
||||||
iid: '{{ otel_iid | default(ansible_default_ipv4.address) }}'
|
|
||||||
- job_name: 'process-exporter'
|
- job_name: 'process-exporter'
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: ['localhost:9256']
|
{% for static_config in process_static_configs %}
|
||||||
|
- targets: {{ static_config.targets | to_json }}
|
||||||
labels:
|
labels:
|
||||||
vendor: '{{ otel_vendor | default("aws") }}'
|
{% for label_key, label_value in static_config.labels.items() %}
|
||||||
account: '{{ otel_account | default("prod") }}'
|
{{ label_key }}: '{{ label_value }}'
|
||||||
group: '{{ otel_group | default("core") }}'
|
{% endfor %}
|
||||||
name: '{{ otel_name | default(inventory_hostname) }}'
|
{% endfor %}
|
||||||
iid: '{{ otel_iid | default(ansible_default_ipv4.address) }}'
|
|
||||||
journald:
|
journald:
|
||||||
directory: /var/log/journal
|
directory: /var/log/journal
|
||||||
filelog/std:
|
filelog/std:
|
||||||
@ -47,11 +50,11 @@ exporters:
|
|||||||
otlphttp/openobserve:
|
otlphttp/openobserve:
|
||||||
endpoint: {{ otlp_endpoint | default('https://otel.svc.plus/api/default/') }}
|
endpoint: {{ otlp_endpoint | default('https://otel.svc.plus/api/default/') }}
|
||||||
headers:
|
headers:
|
||||||
Authorization: "{{ otlp_auth | default('Basic cm9vdEBleGFtcGxlLmNvbTpiNTVkbHFLenVLamZXVXRY') }}"
|
Authorization: "{{ otlp_auth }}"
|
||||||
otlphttp/openobserve_journald:
|
otlphttp/openobserve_journald:
|
||||||
endpoint: {{ otlp_endpoint | default('https://otel.svc.plus/api/default/') }}
|
endpoint: {{ otlp_endpoint | default('https://otel.svc.plus/api/default/') }}
|
||||||
headers:
|
headers:
|
||||||
Authorization: "{{ otlp_auth | default('Basic cm9vdEBleGFtcGxlLmNvbTpiNTVkbHFLenVLamZXVXRY') }}"
|
Authorization: "{{ otlp_auth }}"
|
||||||
stream-name: journald
|
stream-name: journald
|
||||||
|
|
||||||
service:
|
service:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user