From 7b6409384b78fd813cc7e2b60b097b529bffa27b Mon Sep 17 00:00:00 2001 From: Aleksandr Titov <26012167+AleksandrTitov@users.noreply.github.com> Date: Tue, 25 Jul 2023 17:32:30 +0300 Subject: [PATCH] chore: Add an example of using module (#2) --- examples/.placeholder | 0 .../k8s/otel_collector_clickhouse.yaml | 68 +++++++++++++++++++ examples/otel_collector/main.tf | 6 ++ examples/otel_collector/providers.tf | 14 ++++ 4 files changed, 88 insertions(+) delete mode 100644 examples/.placeholder create mode 100644 examples/otel_collector/k8s/otel_collector_clickhouse.yaml create mode 100644 examples/otel_collector/main.tf create mode 100644 examples/otel_collector/providers.tf diff --git a/examples/.placeholder b/examples/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/examples/otel_collector/k8s/otel_collector_clickhouse.yaml b/examples/otel_collector/k8s/otel_collector_clickhouse.yaml new file mode 100644 index 0000000..6c093d6 --- /dev/null +++ b/examples/otel_collector/k8s/otel_collector_clickhouse.yaml @@ -0,0 +1,68 @@ +### +# CRD OpenTelemetry Collector +# API https://github.com/open-telemetry/opentelemetry-operator/blob/42a6d6044efaefd568ceeaec2003dbe35ac3d44d/docs/api.md#opentelemetrycollector +# +# Config: +# * receivers - https://github.com/open-telemetry/opentelemetry-collector/tree/main/receiver/otlpreceiver +# * processors- https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor/batchprocessor +# * exporters: +# * logging - https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/loggingexporter/README.md +# * clickhouse - https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/clickhouseexporter +# * extensions - https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/healthcheckextension/README.md +### +apiVersion: opentelemetry.io/v1alpha1 +kind: OpenTelemetryCollector +metadata: + name: clickhouse + namespace: telemetry +spec: + mode: deployment + config: | + receivers: + otlp: + protocols: + grpc: + + processors: + batch: + timeout: 200ms + send_batch_size: 8192 + + exporters: + clickhouse: + endpoint: tcp://clickhouse:9000?dial_timeout=10s&compress=lz4 + database: otel + username: default + password: default + ttl_days: 14 + logs_table_name: otel_logs + traces_table_name: otel_traces + metrics_table_name: otel_metrics + timeout: 5s + retry_on_failure: + enabled: true + initial_interval: 5s + max_interval: 30s + max_elapsed_time: 300s + + extensions: + health_check: + + service: + telemetry: + logs: + level: debug + extensions: [health_check] + pipelines: + metrics: + receivers: [otlp] + exporters: [clickhouse] + processors: [batch] + traces: + receivers: [otlp] + exporters: [clickhouse] + processors: [batch] + logs: + receivers: [otlp] + exporters: [clickhouse] + processors: [batch] diff --git a/examples/otel_collector/main.tf b/examples/otel_collector/main.tf new file mode 100644 index 0000000..0293252 --- /dev/null +++ b/examples/otel_collector/main.tf @@ -0,0 +1,6 @@ +module "otel_collector_clickhouse" { + source = "cloud-labs-infra/manifest/kubernetes" + version = "1.0.0" + + manifest = yamldecode(file("${path.module}/k8s/otel_collector_clickhouse.yaml")) +} diff --git a/examples/otel_collector/providers.tf b/examples/otel_collector/providers.tf new file mode 100644 index 0000000..90ec414 --- /dev/null +++ b/examples/otel_collector/providers.tf @@ -0,0 +1,14 @@ +terraform { + required_version = "~> 1.4" + + required_providers { + kubernetes = { + source = "hashicorp/kubernetes" + version = "~>2.20" + } + } +} + +provider "kubernetes" { + host = "https://127.0.0.1:443" +}