krakend-ce icon indicating copy to clipboard operation
krakend-ce copied to clipboard

Configure Distributed Tracing With APM Server

Open ReginaldoSantos opened this issue 2 years ago • 0 comments

Environment info: devopsfaith/krakend:2.0.4 successfully deployed with flexible configuration.

Describe what are you trying to do: I have distributed tracing for http requests configured with Elastic APM server (and EFK stack). Thus, BFF in NodeJS, Spring Cloud Gateway and Microservices in Java/Spring are all instrumented with elastic apm agents.

However, we are moving now to KrakenD (replacing Spring Cloud Gateway) and I'm wondering if there is some way to keep using the very same tracing stack.

Is this somehow possible? Could any of the exporters send trace information to APM Server out of the box so it can be visualized in Kibana's APM view?

Your configuration file: krakend.json snippet

{
    "$schema": "https://www.krakend.io/schema/v3.json",
    "version": 3,
    "name": "API Gateway",
    "timeout": "10000ms",
    "cache_ttl": "300s",
    "output_encoding": "no-op",
    "sequential_start": true,
    "extra_config":
    {
        "telemetry/logging":
        {
            "level": "DEBUG",
            "prefix": "[KRAKEND]",
            "syslog": false,
            "stdout": true,
            "format": "logstash"
        }
    },
    "endpoints":
    [
        {
            "endpoint": "/admin/tenants",
            "method": "GET",
            "extra_config":
            {
                "auth/validator":
                {
                    "alg": "RS256",
                    "jwk_url": "http://ms-jwks.backoffice/.well-known/jwks.json",
                    "disable_jwk_security": true,
                    "cache": true,
                    "roles_key_is_nested": true,
                    "roles_key": "resource_access.admin.roles",
                    "roles":
                    [
                        "Admin"
                    ],
                    "scopes_key": "scope",
                    "scopes":
                    [
                        "profile"
                    ],
                    "scopes_matcher": "any",
                    "propagate_claims":
                    [
                        [
                            "realm",
                            "X-TenantId"
                        ]
                    ],
                    "operation_debug": true
                }
            },
            "output_encoding": "no-op",
            "input_headers":
            [
                "*"
            ],
            "input_query_strings":
            [
                "*"
            ],
            "backend":
            [
                {
                    "url_pattern": "/tenants",
                    "method": "GET",
                    "encoding": "no-op",
                    "sd": "static",
                    "disable_host_sanitize": true,
                    "host":
                    [
                        "http://ms-admin.backoffice"
                    ]
                }
            ]
        }
    ]
}

Additional comments:

For example, as both jaeger and apm support OTel, would jaeger exporter work?

        "telemetry/opencensus": {
            "sample_rate": 100,
            "reporting_period": 1,
            "exporters": {
                "jaeger": {
                    "endpoint": "http://apm-server.monitoring:8200",
                    "service_name":"krakend",
                    "buffer_max_count": 1000
                }
            }
        }

If not, is there another way? (maybe setting some communication between jaeger and apm-server?)

ReginaldoSantos avatar Jul 27 '22 17:07 ReginaldoSantos