Back to Graphql Engine

Metadata API Reference: Observability Options

docs/docs/api-reference/metadata-api/observability.mdx

2.49.26.1 KB
Original Source

import ProductBadge from '@site/src/components/ProductBadge';

Metadata API Reference: Observability Options

<ProductBadge ce free pro ee self />

Introduction

The API to manage Observability related metadata configurations.

Logs and metrics configuration

<ProductBadge pro />

These are the configurations that govern the metrics and logging output for debugging and analytics.

set_metrics_config {#metadata-set-metrics-config}

set_metrics_config is used to add/update logs and metrics configurations.

http
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
    "type": "set_metrics_config",
    "args": {
        "analyze_query_variables": false,
        "analyze_response_body": false
    }
}

Args syntax {#set-metrics-config-syntax}

KeyRequiredSchemaDescription
analyze_query_variablestruebooleanEnables logging of the values of the query variables provided for each request. Default is false.
analyze_response_bodytruebooleanEnables logging of the values of the response body for each request. Default is false.

Please see the corresponding feature documentation for the usage of these configurations.

remove_metrics_config {#metadata-remove-metrics-config}

remove_metrics_config is used to remove all metrics configurations.

http
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
    "type": "remove_metrics_config",
    "args": {}
}

OpenTelemetry Configuration

<ProductBadge self />

The OpenTelemetry configuration enables export of distributed traces and metrics to an to an OpenTelemetry compliant APM receiver.

set_opentelemetry_config {#metadata-set-opentelemetry-config}

set_opentelemetry_config is used to add/update OpenTelemetry configuration.

:::info Supported from

OpenTelemetry traces are supported for Hasura GraphQL Engine versions v2.18.0 and above.

:::

http
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
    "type": "set_opentelemetry_config",
    "args": {
        "status": "enabled",
        "data_types": [
            "traces",
            "metrics",
            "logs"
        ],
        "exporter_otlp": {
            "otlp_traces_endpoint": "http://localhost:4318/v1/traces",
            "otlp_metrics_endpoint": "http://localhost:4318/v1/metrics",
            "otlp_logs_endpoint": "http://localhost:4318/v1/logs",
            "protocol": "http/protobuf",
            "traces_propagators": ["tracecontext"],
            "headers": [
                {
                    "name": "x-test-header",
                    "value": "testing"
                },
                {
                    "name": "x-header-from-env",
                    "value_from_env": "TEST_ENV_VAR"
                }
            ],
            "resource_attributes": [
                {
                    "name": "stage",
                    "value": "production"
                },
                {
                    "name": "region",
                    "value": "us-east"
                }
            ]
        },
        "batch_span_processor": {
            "max_export_batch_size": 100
        }
    }
}

Args syntax {#set-opentelemetry-config-syntax}

KeyRequiredSchemaDescription
statusfalseStringToggle to enable or disable the export. Allowed values are enabled and disabled. Default is disabled (If status is not explicitely passed, then the configuration gets disabled)
data_typesfalse[String]List of the types of observability data points to be exported. Allowed types: traces, metrics and logs only
exporter_otlpfalseOTLPExporter. This is required if status is enabledOpenTelemetry compliant receiver configuration
batch_span_processorfalseOpenTelemetryBatchSpanProcessorOpenTelemetry batch export configuration

set_opentelemetry_status {#set-opentelemetry-status}

set_opentelemetry_status is used to set just the status field of the OpenTelemetry configuration, which enable/disable the export to the OpenTelemetry receiver. Other configuration settings are preserved.

:::info Supported from

This is supported for versions v2.18.0 and above.

:::

http
POST /v1/metadata HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin
{
    "type": "set_opentelemetry_status",
    "args": "enabled"
}

Allowed values of args are enabled and disabled