diff --git a/.gitignore b/.gitignore index fb34ac8d..9d1b5557 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ .idea hosts *.log +yala # MacOS # --------------------------------------------------- diff --git a/CODEOWNERS b/CODEOWNERS index 654eb1a6..675a2ad2 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ ./ @ishanjainn /roles/grafana @gardar @ishanjainn -/roles/grafana_agent @ishanjainn @v-zhuravlev +/roles/grafana_agent @ishanjainn @v-zhuravlev @gardar diff --git a/README.md b/README.md index e28604a1..2bcc6375 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Full Integration Test](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml/badge.svg?branch=main)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/full-integration-test.yml) [![Lint](https://github.com/grafana/grafana-ansible-collection/actions/workflows/lint.yaml/badge.svg)](https://github.com/grafana/grafana-ansible-collection/actions/workflows/lint.yaml) -This collection (`grafana.grafana`) contains modules and plugins to assist in automating managing of resources in **Grafana** with Ansible. +This collection (`grafana.grafana`) contains modules and roles to assist in automating the management of resources in **Grafana**, **Grafana Agent**, and **OpenTelemetry Collector** with Ansible. - [Ansible collection Documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/) - [Grafana](https://grafana.com) @@ -46,6 +46,14 @@ collections: version: 1.0.0 ``` +## Roles included in the collection + +This collection includes the following roles to help set up and manage Grafana, Grafana Agent, and OpenTelemetry Collector: + +- **Grafana**: Installs and configures Grafana on your target hosts. +- **Grafana Agent**: Deploys and configures Grafana Agent, allowing for efficient metrics, logs, and trace data shipping to Grafana Cloud or other endpoints. +- **OpenTelemetry Collector**: Sets up and configures the OpenTelemetry Collector, enabling advanced observability features through data collection and transmission. + ## Using this collection You can call modules by their Fully Qualified Collection Namespace (FQCN), such as `grafana.grafana.cloud_stack`: diff --git a/examples/monitor-multiple-instance-otel.md b/examples/monitor-multiple-instance-otel.md new file mode 100644 index 00000000..89762ca1 --- /dev/null +++ b/examples/monitor-multiple-instance-otel.md @@ -0,0 +1,193 @@ +# Scaling OpenTelemetry Collector Deployments Using Grafana Ansible Collection +This guide is focused on scaling the OpenTelemetry Collector deployment across various Linux hosts by leveraging Ansible, to function both as gateways and agents within your observability architecture. Utilizing the OpenTelemetry Collector in this dual capacity enables a robust collection and forwarding of metrics, traces, and logs to analysis and visualization platforms, such as Grafana Cloud. + +Here, we outline a strategy for deploying and managing the OpenTelemetry Collector's scalable instances throughout your infrastructure with Ansible, enhancing your overall monitoring strategy and data visualization capabilities in Grafana Cloud. + +## Before You Begin + +To follow this guide, ensure you have: + +- Linux hosts. +- SSH access to each of these Linux hosts. +- Account permissions to install and configure the OpenTelemetry Collector on these hosts. + +## Install the Grafana Ansible collection + +The [Grafana Agent role](https://github.com/grafana/grafana-ansible-collection/tree/main/roles/grafana_agent) is available in the Grafana Ansible collection as of the 1.1.0 release. + +To install the Grafana Ansible collection, run this command: + +``` +ansible-galaxy collection install grafana.grafana +``` + +## Create an Ansible inventory file + +Next, you will set up your hosts and create an inventory file. + +1. Create your hosts and add public SSH keys to them. + + This example uses eight Linux hosts: two Ubuntu hosts, two CentOS hosts, two Fedora hosts, and two Debian hosts. + +1. Create an Ansible inventory file. + + The Ansible inventory, which resides in a file named `inventory`, looks similar to this: + + ``` + 146.190.208.216 # hostname = ubuntu-01 + 146.190.208.190 # hostname = ubuntu-02 + 137.184.155.128 # hostname = centos-01 + 146.190.216.129 # hostname = centos-02 + 198.199.82.174 # hostname = debian-01 + 198.199.77.93 # hostname = debian-02 + 143.198.182.156 # hostname = fedora-01 + 143.244.174.246 # hostname = fedora-02 + ``` + + > **Note**: If you are copying the above file, remove the comments (#). + +1. Create an `ansible.cfg` file within the same directory as `inventory`, with the following values: + ``` + [defaults] + inventory = inventory # Path to the inventory file + private_key_file = ~/.ssh/id_rsa # Path to my private SSH Key + remote_user=root + ``` + +## Use the OpenTelemetry Collector Ansible Role + +Next, you'll define an Ansible playbook to apply your chosen or created OpenTelemetry Collector role across your hosts. + +Create a file named `deploy-opentelemetry.yml` in the same directory as your `ansible.cfg` and `inventory`. + +```yaml +- name: Install OpenTelemetry Collector + hosts: all + become: true + + vars: + grafana_cloud_api_key: # Example - eyJrIjoiYjI3NjI5MGQxZTcyOTIxYTc0MDgzMGVhNDhlODNhYzA5OTk2Y2U5YiIsIm4iOiJhbnNpYmxldGVzdCIsImlkIjo2NTI5 + metrics_username: # Example - 825019 + logs_username: # Example - 411478 + prometheus_url: # Example - https://prometheus-us-central1.grafana.net/api/prom/push + loki_url: # Example - https://logs-prod-017.grafana.net/loki/api/v1/push + tempo_url: # Example - tempo-prod-04-prod-us-east-0.grafana.net:443 + traces_username: # Example - 411478 + + tasks: + - name: Install OpenTelemetry Collector + ansible.builtin.include_role: + name: grafana.grafana.opentelemetry_collector + vars: + otel_collector_extensions: + basicauth/grafana_cloud_tempo: + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/extension/basicauthextension + client_auth: + username: "{{ traces_username }}" + password: "{{ grafana_cloud_api_key }}" + basicauth/grafana_cloud_prometheus: + client_auth: + username: "{{ prometheus_url }}" + password: "{{ grafana_cloud_api_key }}" + basicauth/grafana_cloud_loki: + client_auth: + username: "{{ logs_username }}" + password: "{{ grafana_cloud_api_key }}" + + + otel_collector_receivers: + otlp: + # https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver + protocols: + grpc: + http: + hostmetrics: + # Optional. Host Metrics Receiver added as an example of Infra Monitoring capabilities of the OpenTelemetry Collector + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver + scrapers: + load: + memory: + + otel_collector_processors: + batch: + # https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor + resourcedetection: + # Enriches telemetry data with resource information from the host + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/resourcedetectionprocessor + detectors: ["env", "system"] + override: false + transform/add_resource_attributes_as_metric_attributes: + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor + error_mode: ignore + metric_statements: + - context: datapoint + statements: + - set(attributes["deployment.environment"], resource.attributes["deployment.environment"]) + - set(attributes["service.version"], resource.attributes["service.version"]) + + otel_collector_exporters: + otlp/grafana_cloud_traces: + # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlpexporter + endpoint: "{{ tempo_url }}" + auth: + authenticator: basicauth/grafana_cloud_tempo + + loki/grafana_cloud_logs: + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/lokiexporter + endpoint: "{{ loki_url }}" + auth: + authenticator: basicauth/grafana_cloud_loki + + prometheusremotewrite/grafana_cloud_metrics: + # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/prometheusremotewriteexporter + endpoint: "{{ prometheus_url }}" + add_metric_suffixes: false + auth: + authenticator: basicauth/grafana_cloud_prometheus + + + otel_collector_service: + extensions: [basicauth/grafana_cloud_tempo, basicauth/grafana_cloud_prometheus, basicauth/grafana_cloud_loki] + pipelines: + traces: + receivers: [otlp] + processors: [resourcedetection, batch] + exporters: [otlp/grafana_cloud_traces] + metrics: + receivers: [otlp, hostmetrics] + processors: [resourcedetection, transform/add_resource_attributes_as_metric_attributes, batch] + exporters: [prometheusremotewrite/grafana_cloud_metrics] + logs: + receivers: [otlp] + processors: [resourcedetection, batch] + exporters: [loki/grafana_cloud_logs] +``` + +> **Note:** You'll need to adjust the configuration to match the specific telemetry data you intend to collect and where you plan to forward it. The configuration snippet above is a basic example designed for traces, logs and metrics collection via OTLP and forwarding to Grafana Cloud. + + +## Running the Ansible Playbook + +Deploy the OpenTelemetry Collector across your hosts by executing: + +```sh +ansible-playbook deploy-opentelemetry.yml +``` + +## Verifying Data Ingestion into Grafana Cloud + +Once you've deployed the OpenTelemetry Collector and configured it to forward data to Grafana Cloud, you can verify the ingestion: + +- Log into your Grafana Cloud instance. +- Navigate to the **Explore** section. +- Select your Grafana Cloud Prometheus data source from the dropdown menu. +- Execute a query to confirm the reception of metrics, e.g., `{instance="ubuntu-01"}` for a specific host's metrics. + +## Visualizing Metrics and Logs in Grafana + +With data successfully ingested into Grafana Cloud, you can create custom dashboards to visualize the metrics, logs and traces received from your OpenTelemetry Collector. Utilize Grafana's powerful query builder and visualization tools to derive insights from your data effectively. + +- Consider creating dashboards that offer a comprehensive overview of your infrastructure's health and performance. +- Utilize Grafana's alerting features to proactively manage and respond to issues identified through the OpenTelemetry data. + +This guide simplifies the deployment of the OpenTelemetry Collector across multiple Linux hosts using Ansible and illustrates how to visualize collected telemetry data in Grafana Cloud. Tailor the Ansible roles, OpenTelemetry Collector configurations, and Grafana dashboards to suit your specific monitoring and observability requirements. diff --git a/examples/monitor-multiple-instances.md b/examples/monitor-multiple-instances-agent.md similarity index 100% rename from examples/monitor-multiple-instances.md rename to examples/monitor-multiple-instances-agent.md diff --git a/examples/opentelemetry-collector.yml b/examples/opentelemetry-collector.yml new file mode 100644 index 00000000..445a3a26 --- /dev/null +++ b/examples/opentelemetry-collector.yml @@ -0,0 +1,43 @@ +- name: Install OpenTelemetry Collector + hosts: all + become: true + + tasks: + - name: Install OpenTelemetry Collector + ansible.builtin.include_role: + name: grafana.grafana.opentelemetry_collector + vars: + otel_collector_receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + otel_collector_processors: + batch: + + otel_collector_exporters: + otlp: + endpoint: otelcol:4317 + + otel_collector_extensions: + health_check: + pprof: + zpages: + + otel_collector_service: + extensions: [health_check, pprof, zpages] + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [otlp] + metrics: + receivers: [otlp] + processors: [batch] + exporters: [otlp] + logs: + receivers: [otlp] + processors: [batch] + exporters: [otlp] diff --git a/roles/grafana_agent/README.md b/roles/grafana_agent/README.md index 185281a8..c3fa74f5 100644 --- a/roles/grafana_agent/README.md +++ b/roles/grafana_agent/README.md @@ -1,4 +1,4 @@ -# Role Name +# Ansible Role for Grafana Agent Ansible Role to deploy Grafana Agent on Linux hosts. Using this Role, Grafana Agent can be deployed on RedHat, Ubuntu, Debian, CentOS and Fedora linux distributions. diff --git a/roles/opentelemetry_collector/README.md b/roles/opentelemetry_collector/README.md new file mode 100644 index 00000000..11c7cda6 --- /dev/null +++ b/roles/opentelemetry_collector/README.md @@ -0,0 +1,100 @@ +# Ansible Role for OpenTelemetry Collector + +This Ansible role to install and configure the OpenTelemetry Collector, which can be used to collect traces, metrics, and logs. + +## Requirements + +Please ensure that `curl` is intalled on Ansible controller. + +## Role Variables + +Available variables with their default values are listed below (`defaults/main.yml`): + +| Variable Name | Description | Default Value | +|---------------|-------------|---------------| +| `otel_collector_version` | Version of OpenTelemetry Collector to install. | `"0.90.1"` | +| `otel_collector_binary_url` | URL for downloading the OpenTelemetry Collector binary. This URL is constructed based on the collector version, type, and architecture. | `"https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v{{ otel_collector_version }}/{% if otel_collector_type == 'contrib' %}otelcol-contrib_{{ otel_collector_version }}_linux_{{ otel_collector_arch }}{% else %}otelcol_{{ otel_collector_version }}_linux_{{ otel_collector_arch }}{% endif %}.tar.gz"` | +| `arch_mapping` | Mapping of `ansible_architecture` values to OpenTelemetry Collector binary architecture names. | See below\* | +| `otel_collector_arch` | Architecture for the OpenTelemetry Collector binary, determined based on the `ansible_architecture` fact. | `"{{ arch_mapping[ansible_architecture] | default('amd64') }}"` | +| `otel_collector_service_name` | The service name for the OpenTelemetry Collector. | `"otel-collector"` | +| `otel_collector_type` | Type of the OpenTelemetry Collector (`contrib` includes additional components). | `contrib` | +| `otel_collector_executable` | The executable name of the OpenTelemetry Collector, changes based on the collector type. | `{% if otel_collector_type == 'contrib' %}otelcol-contrib{% else %}otelcol{% endif %}` | +| `otel_collector_installation_dir` | Installation directory for the OpenTelemetry Collector. | `"/etc/otel-collector"` | +| `otel_collector_config_dir` | Directory for OpenTelemetry Collector configuration files. | `"/etc/otel-collector"` | +| `otel_collector_config_file` | The main configuration file name for the OpenTelemetry Collector. | `"config.yaml"` | +| `otel_collector_service_user` | The system user under which the OpenTelemetry Collector service will run. | `"otel"` | +| `otel_collector_service_group` | The system group under which the OpenTelemetry Collector service will run. | `"otel"` | +| `otel_collector_receivers` | Receivers configuration for the OpenTelemetry Collector. | `""` | +| `otel_collector_exporters` | Exporters configuration for the OpenTelemetry Collector. | `""` | +| `otel_collector_processors` | Processors configuration for the OpenTelemetry Collector. | `""` | +| `otel_collector_extensions` | Extensions configuration for the OpenTelemetry Collector. | `""` | +| `otel_collector_service` | Service configuration for the OpenTelemetry Collector. | `""` | +| `otel_collector_connectors` | Connectors configuration for the OpenTelemetry Collector (optional). | `""` | + +\* For `arch_mapping`, the default mapping is as follows: +- `x86_64`: `amd64` +- `aarch64`: `arm64` +- `armv7l`: `armhf` +- `i386`: `i386` +- `ppc64le`: `ppc64le` + +Users of the role can override these variables as needed. + +## Example Playbook + +Include this role in your playbook with default settings: + +```yaml +- name: Install OpenTelemetry Collector + hosts: all + become: true + + tasks: + - name: Install OpenTelemetry Collector + ansible.builtin.include_role: + name: grafana.grafana.opentelemetry_collector + vars: + otel_collector_receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + otel_collector_processors: + batch: + + otel_collector_exporters: + otlp: + endpoint: otelcol:4317 + + otel_collector_extensions: + health_check: + pprof: + zpages: + + otel_collector_service: + extensions: [health_check, pprof, zpages] + pipelines: + traces: + receivers: [otlp] + processors: [batch] + exporters: [otlp] + metrics: + receivers: [otlp] + processors: [batch] + exporters: [otlp] + logs: + receivers: [otlp] + processors: [batch] + exporters: [otlp] + +``` + +## License + +See [LICENSE](https://github.com/grafana/grafana-ansible-collection/blob/main/LICENSE) + +## Author Information + +- [Ishan Jain](https://github.com/ishanjainn) diff --git a/roles/opentelemetry_collector/defaults/main.yml b/roles/opentelemetry_collector/defaults/main.yml new file mode 100644 index 00000000..f615b6c7 --- /dev/null +++ b/roles/opentelemetry_collector/defaults/main.yml @@ -0,0 +1,27 @@ +otel_collector_version: "0.90.1" + +otel_collector_binary_url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v{{ otel_collector_version }}/{% if otel_collector_type == 'contrib' %}otelcol-contrib_{{ otel_collector_version }}_linux_{{ otel_collector_arch }}{% else %}otelcol_{{ otel_collector_version }}_linux_{{ otel_collector_arch }}{% endif %}.tar.gz" + +arch_mapping: + x86_64: amd64 + aarch64: arm64 + armv7l: armhf + i386: i386 + ppc64le: ppc64le + +otel_collector_arch: "{{ arch_mapping[ansible_architecture] | default('amd64') }}" +otel_collector_service_name: "otel-collector" +otel_collector_type: contrib +otel_collector_executable: "{% if otel_collector_type == 'contrib' %}otelcol-contrib{% else %}otelcol{% endif %}" +otel_collector_installation_dir: "/etc/otel-collector" +otel_collector_config_dir: "/etc/otel-collector" +otel_collector_config_file: "config.yaml" +otel_collector_service_user: "otel" +otel_collector_service_group: "otel" + +otel_collector_receivers: "" +otel_collector_exporters: "" +otel_collector_processors: "" +otel_collector_extensions: "" +otel_collector_service: "" +otel_collector_connectors: "" diff --git a/roles/opentelemetry_collector/handlers/main.yml b/roles/opentelemetry_collector/handlers/main.yml new file mode 100644 index 00000000..b5bbf355 --- /dev/null +++ b/roles/opentelemetry_collector/handlers/main.yml @@ -0,0 +1,5 @@ +- name: Restart OpenTelemetry Collector + ansible.builtin.systemd: + name: "{{ otel_collector_service_name }}" + state: restarted + become: true diff --git a/roles/opentelemetry_collector/meta/main.yml b/roles/opentelemetry_collector/meta/main.yml new file mode 100644 index 00000000..edd9779c --- /dev/null +++ b/roles/opentelemetry_collector/meta/main.yml @@ -0,0 +1,25 @@ +galaxy_info: + author: Ishan Jain + description: Role to install and configure OpenTelemetry Collector + license: "GPL-3.0-or-later" + min_ansible_version: "2.11" + platforms: + - name: Fedora + versions: + - "all" + - name: Debian + versions: + - "all" + - name: Ubuntu + versions: + - "all" + - name: EL + versions: + - "all" + galaxy_tags: + - grafana + - observability + - monitoring + - opentelemetry + - telemetry + - collector diff --git a/roles/opentelemetry_collector/tasks/configure.yml b/roles/opentelemetry_collector/tasks/configure.yml new file mode 100644 index 00000000..3d5f57ac --- /dev/null +++ b/roles/opentelemetry_collector/tasks/configure.yml @@ -0,0 +1,18 @@ +- name: Create OpenTelemetry Collector config directory + ansible.builtin.file: + path: "{{ otel_collector_config_dir }}" + state: directory + owner: "{{ otel_collector_service_user }}" + group: "{{ otel_collector_service_group }}" + mode: '0755' + become: true + +- name: Deploy OpenTelemetry Collector configuration file + ansible.builtin.template: + src: otel_collector_config.yml.j2 + dest: "{{ otel_collector_config_dir }}/{{ otel_collector_config_file }}" + owner: "{{ otel_collector_service_user }}" + group: "{{ otel_collector_service_group }}" + mode: '0644' + notify: Restart OpenTelemetry Collector + become: true diff --git a/roles/opentelemetry_collector/tasks/install.yml b/roles/opentelemetry_collector/tasks/install.yml new file mode 100644 index 00000000..0e4e87b9 --- /dev/null +++ b/roles/opentelemetry_collector/tasks/install.yml @@ -0,0 +1,56 @@ +- name: Create otel group + ansible.builtin.group: + name: "{{ otel_collector_service_group }}" + system: true + become: true + +- name: Create otel user + ansible.builtin.user: + name: "{{ otel_collector_service_user }}" + group: "{{ otel_collector_service_group }}" + system: true + create_home: false # Appropriate for a system user, usually doesn't need a home directory + become: true + +- name: Determine the architecture for OpenTelemetry Collector binary + set_fact: + otel_collector_arch: "{{ arch_mapping[ansible_architecture] | default('amd64') }}" + vars: + arch_mapping: + x86_64: amd64 + aarch64: arm64 + armv7l: armhf + i386: i386 + ppc64le: ppc64le + +- name: Download OpenTelemetry Collector binary + ansible.builtin.get_url: + url: "{{ otel_collector_binary_url }}" + dest: "/tmp/otelcol-{{ otel_collector_type }}-{{ otel_collector_version }}.tar.gz" + mode: '0755' + become: true + register: download_result + +- name: Remove existing OpenTelemetry Collector installation directory + ansible.builtin.file: + path: "{{ otel_collector_installation_dir }}" + state: absent + become: true + when: download_result.changed + +- name: Create OpenTelemetry Collector installation directory + ansible.builtin.file: + path: "{{ otel_collector_installation_dir }}" + state: directory + mode: '0755' + owner: "{{ otel_collector_service_user }}" + group: "{{ otel_collector_service_group }}" + become: true + +- name: Extract OpenTelemetry Collector binary + ansible.builtin.unarchive: + src: "/tmp/otelcol-{{ otel_collector_type }}-{{ otel_collector_version }}.tar.gz" + dest: "{{ otel_collector_installation_dir }}" + remote_src: yes + become: true + register: extract_result diff --git a/roles/opentelemetry_collector/tasks/main.yml b/roles/opentelemetry_collector/tasks/main.yml new file mode 100644 index 00000000..6557285f --- /dev/null +++ b/roles/opentelemetry_collector/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Install OpenTelemetry Collector + include_tasks: install.yml + tags: [install] + +- name: Configure OpenTelemetry Collector + include_tasks: configure.yml + tags: [configure] + +- name: Manage OpenTelemetry Collector service + include_tasks: service.yml + tags: [service] diff --git a/roles/opentelemetry_collector/tasks/service.yml b/roles/opentelemetry_collector/tasks/service.yml new file mode 100644 index 00000000..6de6e8fe --- /dev/null +++ b/roles/opentelemetry_collector/tasks/service.yml @@ -0,0 +1,19 @@ +- name: Copy OpenTelemetry Collector systemd unit file + ansible.builtin.template: + src: otel_collector.service.j2 + dest: /etc/systemd/system/{{ otel_collector_service_name }}.service + mode: '0644' + become: true + notify: Restart OpenTelemetry Collector + +- name: Reload systemd daemon to pick up changes + ansible.builtin.systemd: + daemon_reload: yes + become: true + +- name: Ensure OpenTelemetry Collector service is enabled and running + ansible.builtin.service: + name: "{{ otel_collector_service_name }}" + enabled: yes + state: started + become: true diff --git a/roles/opentelemetry_collector/templates/otel_collector.service.j2 b/roles/opentelemetry_collector/templates/otel_collector.service.j2 new file mode 100644 index 00000000..79b35bec --- /dev/null +++ b/roles/opentelemetry_collector/templates/otel_collector.service.j2 @@ -0,0 +1,13 @@ +[Unit] +Description=OpenTelemetry Collector +After=network.target + +[Service] +Type=simple +ExecStart={{ otel_collector_installation_dir }}/{{ otel_collector_executable }} --config={{ otel_collector_config_dir }}/{{ otel_collector_config_file }} +User={{ otel_collector_service_user }} +Group={{ otel_collector_service_group }} +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/roles/opentelemetry_collector/templates/otel_collector_config.yml.j2 b/roles/opentelemetry_collector/templates/otel_collector_config.yml.j2 new file mode 100644 index 00000000..98481f9b --- /dev/null +++ b/roles/opentelemetry_collector/templates/otel_collector_config.yml.j2 @@ -0,0 +1,14 @@ +receivers: +{{ otel_collector_receivers | to_nice_yaml(indent=2) | indent(2, true) }} +processors: +{{ otel_collector_processors | to_nice_yaml(indent=2) | indent(2, true) }} +exporters: +{{ otel_collector_exporters | to_nice_yaml(indent=2) | indent(2, true) }} +extensions: +{{ otel_collector_extensions | to_nice_yaml(indent=2) | indent(2, true) }} +service: +{{ otel_collector_service | to_nice_yaml(indent=2) | indent(2, true) }} +{% if otel_collector_connectors is defined and otel_collector_connectors | length > 0 %} +connectors: +{{ otel_collector_connectors | to_nice_yaml(indent=2) | indent(2, true) }} +{% endif %}