From 4046187d95940dc3b19de81ae237cff6b087ec00 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Wed, 18 Dec 2024 22:46:35 +0700 Subject: [PATCH] docs: add more OpenTelemetry collector configuration examples PR-URL: https://github.com/hasura/graphql-engine-mono/pull/11116 GitOrigin-RevId: 7b341b9ae84b0eb90ad87ac0878020fb0b6f9f88 --- .../observability/enterprise/dotenv | 2 +- .../otel-collector/otel-collector-config.yaml | 63 ++++++++++++++++--- .../opentelemetry/best-practices.mdx | 2 + 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/community/boilerplates/observability/enterprise/dotenv b/community/boilerplates/observability/enterprise/dotenv index 01fe5bb3a7c3c..5c5f1a58df180 100644 --- a/community/boilerplates/observability/enterprise/dotenv +++ b/community/boilerplates/observability/enterprise/dotenv @@ -1,5 +1,5 @@ # HGE -HGE_IMAGE=hasura/graphql-engine:v2.40.0.cli-migrations-v3 +HGE_IMAGE=hasura/graphql-engine:v2.45.1.cli-migrations-v3 HGE_PORT=8080 HGE_PRO_KEY= HGE_EE_LICENSE_KEY= diff --git a/community/boilerplates/observability/enterprise/otel-collector/otel-collector-config.yaml b/community/boilerplates/observability/enterprise/otel-collector/otel-collector-config.yaml index 1b13a48dc6382..6d380f1d4a780 100644 --- a/community/boilerplates/observability/enterprise/otel-collector/otel-collector-config.yaml +++ b/community/boilerplates/observability/enterprise/otel-collector/otel-collector-config.yaml @@ -22,10 +22,10 @@ exporters: # key: ${DD_API_KEY} ## New Relic exporter - otlp/newrelic: - endpoint: otlp.nr-data.net:4317 - headers: - api-key: ${NEW_RELIC_API_KEY} + # otlp/newrelic: + # endpoint: otlp.nr-data.net:4317 + # headers: + # api-key: ${NEW_RELIC_API_KEY} ## Export traces to Jaeger via OTLP protocol. ## You can also export traces directly to jaeger to graphql-engine. @@ -51,8 +51,12 @@ exporters: ## download and rename to gcp-sa.json so the otel-collector can mount the service account ## # googlecloud: + # trace: + # metric: + # compression: gzip # log: # default_log_name: example-otel.io/hasura-exported-log + # compression: gzip processors: batch: @@ -113,9 +117,50 @@ processors: logs: log_record: - # You can filter unused logs to save cost, or configure HASURA_GRAPHQL_ENABLED_LOG_TYPES in GraphQL Engine to disable unused log types - - 'attributes["type"] == "query-log" and IsMatch(body["query"]["operationName"], "UnknownQuery")' - - 'attributes["type"] == "http-log" and IsMatch(body["operation"]["query"]["operationName"], "UnknownQuery")' + ## Disable debug logs. You can also set HASURA_GRAPHQL_LOG_LEVEL=info. + - severity_number == SEVERITY_NUMBER_DEBUG + + ## Deprecated log types. You should export OTEL traces and metrics instead. + - 'attributes["type"] == "metrics" or attributes["type"] == "tracing-log" or attributes["type"] == "livequery-poller-log"' + + ## http-log and websocket-log already include most of information in query-log. + ## You can ignore this log type unless you want to debug generated SQL. + # - 'attributes["type"] == "query-log"' + + ## You can filter unused logs to save cost, or configure HASURA_GRAPHQL_ENABLED_LOG_TYPES in GraphQL Engine to disable unused log types + # - 'attributes["type"] == "query-log" and IsMatch(body["query"]["operationName"], "UnknownQuery")' + # - 'attributes["type"] == "http-log" and IsMatch(body["operation"]["query"]["operationName"], "UnknownQuery")' + + transform/logs: + error_mode: ignore + log_statements: + ## Remove the transform context in trigger logs + # - context: log + # conditions: + # - 'attributes["type"] == "scheduled-trigger" or attributes["type"] == "event-trigger"' + # statements: + # - 'delete_key(body["request"], "req_transform_ctx")' + + ## Truncate very long query strings in http-log + - context: log + conditions: + - 'attributes["type"] == "http-log" and IsMap(body["operation"])' + statements: + - 'truncate_all(body["operation"], 4096)' + + ## Truncate very long query strings in http-log + - context: log + conditions: + - 'attributes["type"] == "websocket-log" and IsMap(body["event.detail.query"])' + statements: + - 'truncate_all(body["event.detail.query"], 4096)' + + ## Truncate very long generated_sql strings in query-log + - context: log + conditions: + - 'attributes["type"] == "query-log" and IsMap(body["generated_sql"])' + statements: + - 'truncate_all(body["generated_sql"], 4096)' service: pipelines: @@ -126,8 +171,8 @@ service: logs: receivers: [otlp] - processors: [filter, memory_limiter, batch] - exporters: [loki] + processors: [filter, transform/logs, memory_limiter, batch] + exporters: [loki, debug] metrics: receivers: [otlp] diff --git a/docs/docs/observability/opentelemetry/best-practices.mdx b/docs/docs/observability/opentelemetry/best-practices.mdx index 43cb417bf82f7..fe7b06d9f3034 100644 --- a/docs/docs/observability/opentelemetry/best-practices.mdx +++ b/docs/docs/observability/opentelemetry/best-practices.mdx @@ -85,6 +85,8 @@ processors: - 'attributes["type"] == "http-log" and IsMatch(body["operation"]["query"]["operationName"], "UnknownQuery")' ``` +Check out more configuration examples [here](https://github.com/hasura/graphql-engine/blob/master/community/boilerplates/observability/enterprise/otel-collector/otel-collector-config.yaml). + ## Monitoring ### Logging