News Improving The Developer Experience of Your APIs

Community Documentation

Recent changes

Google Cloud and Stackdriver Integration

Document updated on Oct 24, 2022

Google Cloud’s Operation Suite (formerly Stackdriver) aggregates metrics, logs, and events from infrastructure, giving developers and operators a rich set of observable signals that speed root-cause analysis and reduce mean time to resolution (MTTR).

The Opencensus exporter allows you to export metrics and traces to Google Cloud. Enabling it only requires you to add the stackdriver exporter in the opencensus module.

The following configuration snippet sends the data:

  "extra_config": {
    "telemetry/opencensus": {
      "sample_rate": 100,
      "reporting_period": 60,
      "enabled_layers": {
        "backend": true,
        "router": true,
        "pipe": true
      "exporters": {
        "stackdriver": {
          "project_id": "my-krakend-project",
          "metric_prefix": "krakend",
          "default_labels": {
            "env": "production"

As with all OpenCensus exporters, you can add optional settings in the telemetry/opencensus level:

Fields of "telemetry/opencensus"
* required fields

Lets you specify what data you want to export. All layers are enabled by default unless you declare this section.

Reports the activity between KrakenD and your services
Defaults to false

Reports the activity at the beginning of the proxy layer. It gives a more detailed view of the internals of the pipe between end-users and KrakenD, having into account merging of different backends.
Defaults to false

Reports the activity between end-users and KrakenD
Defaults to false

The number of seconds passing between reports. If duration is less than or equal to zero, it enables the default behavior of each exporter.
Defaults to 0

A number between 0 (no requests at all) and 100 (all requests) representing the percentage of sampled requests you want to send to the exporter. Sampling the 100% of the requests is generally discouraged when the relationship between traffic and dedicated resources is sparse.
Defaults to 0

Then, the exporters key must contain an stackdriver entry with the following properties:

Fields of "telemetry/opencensus": { "exporters":{} }
* required fields

Export metrics and traces to Google Cloud
default_labels  *

A map object. Enter here any label that will be assigned by default to the reported metric so you can filter later on Stack Driver.
Example: {"env":"production"}

A prefix that you can add to all your metrics for better organization.
project_id  *

The identifier of your Google Cloud project. The project_id is not the project name. You can omit this value from the configuration if you have an application credential file for Google.
Example: "ID"
Defaults to ""

See also the additional settings of the Opencensus module that can be declared.

Google does not accept low reporting periods
The number of seconds passing between reports in reporting_period must be 60 or greater, otherwise, Google will reject the connection.

Authentication to Google Cloud

The exporter searches for the Application Default Credentials. It looks for credentials in the following places, preferring the first location found:

  1. A JSON file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
  2. A JSON file in a location known to the gcloud command-line tool (e.g.: $HOME/.config/gcloud/application_default_credentials.json).
  3. On Google Compute Engine and Google App Engine flexible environment, it fetches credentials from the metadata server.


Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.