set up otel stack

This commit is contained in:
Jef Roosens 2026-04-04 21:59:17 +02:00
parent 74f8edf024
commit f58bf336d6
Signed by: Jef Roosens
GPG key ID: 21FD3D77D56BAF49
16 changed files with 2423 additions and 0 deletions

View file

@ -0,0 +1,3 @@
otel_metrics_endpoint: 'http://127.0.0.1:4000/v1/otlp'
otel_logs_endpoint: 'http://127.0.0.1:4000/v1/otlp'
otel_traces_endpoint: 'http://127.0.0.1:4000/v1/otlp'

View file

@ -0,0 +1,2 @@
[Service]
User=0

View file

@ -0,0 +1,6 @@
---
- name: 'restart otelcol-contrib'
ansible.builtin.service:
name: 'otelcol-contrib'
state: 'restarted'
daemon_reload: true

View file

@ -0,0 +1,42 @@
---
- name: Ensure collector is installed
ansible.builtin.apt:
deb: 'https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.146.1/otelcol-contrib_0.146.1_linux_amd64.deb'
notify: 'restart otelcol-contrib'
- name: Ensure configuration directory is present
ansible.builtin.file:
path: '/etc/otelcol-contrib'
state: directory
mode: '0755'
- name: Ensure config file is present
ansible.builtin.template:
src: 'config.yaml.j2'
dest: '/etc/otelcol-contrib/config.yaml'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart otelcol-contrib'
- name: Ensure Systemd override directory is present
ansible.builtin.file:
path: '/etc/systemd/system/otelcol-contrib.service.d'
state: 'directory'
mode: '0644'
owner: 'root'
group: 'root'
- name: Ensure Systemd override file is present
ansible.builtin.copy:
src: 'run_as_root.conf'
dest: '/etc/systemd/system/otelcol-contrib.service.d/run_as_root.conf'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart otelcol-contrib'
- name: Ensure service is enabled
ansible.builtin.service:
name: 'otelcol-contrib'
enabled: true

View file

@ -0,0 +1,90 @@
# https://uptrace.dev/opentelemetry/collector#installation
# Receivers configure how data gets into the Collector
receivers:
otlp:
protocols:
grpc:
http:
hostmetrics:
collection_interval: 10s
scrapers:
cpu:
memory:
disk:
filesystem:
network:
load:
prometheus:
config:
scrape_configs:
- job_name: 'caddy'
scrape_interval: 1m
static_configs:
- targets: ['localhost:2019']
- job_name: 'miniflux'
scrape_interval: 30s
static_configs:
- targets: ['localhost:8002']
- job_name: 'restic-rest'
scrape_interval: 30s
static_configs:
- targets: ['localhost:8000']
# Processors specify what happens with the received data
processors:
resourcedetection:
detectors: [env, system]
# cumulativetodelta:
batch:
send_batch_size: 10000
timeout: 10s
exporters:
otlphttp/traces:
endpoint: '{{ otel_traces_endpoint }}'
# auth:
# authenticator: basicauth/client
headers:
# x-greptime-db-name: '<your_db_name>'
x-greptime-pipeline-name: 'greptime_trace_v1'
tls:
insecure: true
otlphttp/logs:
endpoint: '{{ otel_logs_endpoint }}'
# auth:
# authenticator: basicauth/client
headers:
# x-greptime-db-name: '<your_db_name>'
# x-greptime-log-table-name: '<table_name>'
# x-greptime-pipeline-name: '<pipeline_name>'
tls:
insecure: true
otlphttp/metrics:
endpoint: '{{ otel_metrics_endpoint }}'
# auth:
# authenticator: basicauth/client
headers:
x-greptime-otlp-metric-promote-all-resource-attrs: 'true'
# x-greptime-db-name: '<your_db_name>'
tls:
insecure: true
# Service pipelines pull the configured receivers, processors, and exporters together
# into pipelines that process data
#
# Note: Receivers, processors, and exporters not used in pipelines are silently ignored
service:
pipelines:
metrics:
receivers: [otlp, hostmetrics, prometheus]
processors: [batch, resourcedetection]
exporters: [otlphttp/metrics]
traces:
receivers: [otlp]
processors: [batch, resourcedetection]
exporters: [otlphttp/traces]
logs:
receivers: [otlp]
processors: [batch, resourcedetection]
exporters: [otlphttp/logs]