{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "https://www.krakend.io/schema/v2.13/telemetry/opencensus.json",
  "title": "Telemetry via Opencensus",
  "description": "Enables the extended logging capabilities.\n\nSee: https://www.krakend.io/docs/telemetry/opencensus/",
  "type": "object",
  "required": [ "exporters" ],
  "properties": {
    "enabled_layers": {
      "title": "Enabled Layers",
      "description": "Lets you specify what data you want to export. All layers are enabled by default unless you declare this section.",
      "properties": {
        "backend": {
          "title": "Report backend",
          "description": "Reports the activity between KrakenD and your services",
          "default": false,
          "type": "boolean"
        },
        "pipe": {
          "title": "Report pipe",
          "description": "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.",
          "default": false,
          "type": "boolean"
        },
        "router": {
          "title": "Report router",
          "description": "Reports the activity between end-users and KrakenD",
          "default": false,
          "type": "boolean"
        }
      },
      "patternProperties": {
        "^[@$_#]": true
      },
      "additionalProperties": false
    },
    "exporters": {
      "title": "Exporters",
      "description": "The exporter(s) you would like to enable. See each exporter configuration in its own section.",
      "type": "object",
      "minProperties": 1,
      "properties": {
        "datadog": {
          "title": "Datadog",
          "description": "Datadog is a monitoring and security platform for developers, IT operations teams and business in the cloud.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
          "type": "object",
          "required": [
            "namespace",
            "service",
            "trace_address",
            "stats_address",
            "tags",
            "global_tags",
            "disable_count_per_buckets"
          ],
          "properties": {
            "disable_count_per_buckets": {
              "title": "Disable count per buckets",
              "description": "Specifies whether to emit count_per_bucket metrics.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "default": false,
              "type": "boolean"
            },
            "global_tags": {
              "title": "Global tags",
              "description": "A set of tags (key/value) that will automatically be applied to all exported spans.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "examples": [
                {
                  "env": "prod"
                }
              ],
              "type": "object"
            },
            "namespace": {
              "title": "Namespace",
              "description": "The namespace to which metric keys are appended.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "type": "string"
            },
            "service": {
              "title": "Service",
              "description": "Service specifies the service name used for tracing\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "examples": [ "gateway" ],
              "type": "string"
            },
            "stats_address": {
              "title": "Stats address",
              "description": "Specifies the host[:port] address for DogStatsD. To enable ingestion using Unix Domain Socket (UDS) mount your UDS path and reference it in the stats_address using a path like `unix:///var/run/datadog/dsd.socket`.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "examples": [ "localhost:8125" ],
              "default": "localhost:8125",
              "type": "string"
            },
            "tags": {
              "title": "Tags",
              "description": "Specifies a set of global tags to attach to each metric.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "trace_address": {
              "title": "Trace address",
              "description": "Specifies the host[:port] address of the Datadog Trace Agent.\n\nSee: https://www.krakend.io/docs/telemetry/datadog/",
              "default": "localhost:8126",
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "influxdb": {
          "title": "Influxdb",
          "description": "Exports data to InfluxDB: A time series database designed to handle high write and query loads.\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
          "type": "object",
          "required": [ "address", "db" ],
          "properties": {
            "address": {
              "title": "Address",
              "description": "The URL (including port) where your InfluxDB is installed.\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
              "examples": [ "http://192.168.99.100:8086" ],
              "type": "string"
            },
            "db": {
              "title": "DB name",
              "description": "The database name\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
              "examples": [ "krakend" ],
              "type": "string"
            },
            "password": {
              "title": "Password",
              "description": "The password to access the database\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
              "examples": [ "kr4k3nd" ],
              "type": "string"
            },
            "timeout": {
              "title": "Timeout",
              "description": "The maximum time you will wait for InfluxDB to respond.\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
              "examples": [ "2s" ],
              "$ref": "../timeunits.json#/$defs/timeunit",
              "type": "string"
            },
            "username": {
              "title": "Username",
              "description": "The influxdb username to access the database\n\nSee: https://www.krakend.io/docs/telemetry/influxdb/",
              "examples": [ "krakend" ],
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "jaeger": {
          "title": "Jaeger",
          "description": "Submit spans to a Jaeger Collector (HTTP) with `endpoint` or to a Jaeger Agent (UDP) with `agent_endpoint`. \n\nSee https://www.krakend.io/docs/telemetry/jaeger/",
          "type": "object",
          "oneOf": [
            {
              "required": [ "endpoint", "service_name" ]
            },
            {
              "required": [ "agent_endpoint", "service_name" ]
            }
          ],
          "properties": {
            "agent_endpoint": {
              "title": "Agent Endpoint",
              "description": "The address where the Jaeger Agent is (Thrift over UDP), e.g., `jaeger:6831`\n\nSee: https://www.krakend.io/docs/telemetry/jaeger/",
              "examples": [ "http://192.168.99.100:14268/api/traces" ],
              "type": "string"
            },
            "buffer_max_count": {
              "title": "Buffer max count",
              "description": "Total number of traces to buffer in memory\n\nSee: https://www.krakend.io/docs/telemetry/jaeger/",
              "type": "integer"
            },
            "endpoint": {
              "title": "Collector Endpoint",
              "description": "The full URL including port indicating where your Jaeger Collector is (Thrift over HTTP/S), e.g., `http://jaeger:14268/api/traces`\n\nSee: https://www.krakend.io/docs/telemetry/jaeger/",
              "examples": [ "http://192.168.99.100:14268/api/traces" ],
              "type": "string"
            },
            "service_name": {
              "title": "Service name",
              "description": "The service name registered in Jaeger\n\nSee: https://www.krakend.io/docs/telemetry/jaeger/",
              "examples": [ "krakend" ],
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "logger": {
          "title": "Logger",
          "description": "Opencensus can export data to the system logger as another exporter. Recommended to use `telemetry/logging` instead.\n\nSee: https://www.krakend.io/docs/telemetry/logger/",
          "type": "object",
          "properties": {
            "spans": {
              "title": "Spans",
              "description": "Whether to log the spans or not",
              "default": false,
              "type": "boolean"
            },
            "stats": {
              "title": "Stats",
              "description": "Whether to log the statistics or not",
              "default": false,
              "type": "boolean"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "ocagent": {
          "title": "Ocagent",
          "description": "Exporting metrics, logs, and events to the OpenCensus Agent.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
          "type": "object",
          "required": [ "address", "service_name" ],
          "properties": {
            "address": {
              "title": "Address",
              "description": "The address of your Azure Monitor collector.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "examples": [ "localhost:55678" ],
              "type": "string"
            },
            "enable_compression": {
              "title": "Enable compression",
              "description": "Whether to send data compressed or not.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "default": false,
              "type": "boolean"
            },
            "headers": {
              "title": "Headers",
              "description": "List of keys and values for the headers sent. Keys and values must be of type string.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "examples": [
                {
                  "header1": "value1"
                }
              ],
              "type": "object"
            },
            "insecure": {
              "title": "Insecure",
              "description": "Whether the connection can be established in plain (insecure) or not.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "default": false,
              "type": "boolean"
            },
            "reconnection": {
              "title": "Reconnection",
              "description": "The reconnection time\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "default": "2s",
              "$ref": "../timeunits.json#/$defs/timeunit",
              "type": "string"
            },
            "service_name": {
              "title": "Service name",
              "description": "An identifier of your service, e.g, `krakend`.\n\nSee: https://www.krakend.io/docs/telemetry/ocagent/",
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "prometheus": {
          "title": "Prometheus",
          "description": "Prometheus is an open-source systems monitoring and alerting toolkit.",
          "type": "object",
          "required": [ "port" ],
          "properties": {
            "namespace": {
              "title": "Namespace",
              "description": "Sets the domain the metric belongs to.\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "type": "string"
            },
            "port": {
              "title": "Port",
              "description": "Port on which the Prometheus exporter should listen\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "examples": [ 9091 ],
              "type": "integer"
            },
            "tag_host": {
              "title": "Tag host",
              "description": "Whether to send the host as a metric or not.\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "default": false,
              "type": "boolean"
            },
            "tag_method": {
              "title": "Tag method",
              "description": "Whether to send the HTTP method as a metric or not.\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "default": true,
              "type": "boolean"
            },
            "tag_path": {
              "title": "Tag path",
              "description": "Whether to send the path as a metric or not.\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "default": false,
              "type": "boolean"
            },
            "tag_statuscode": {
              "title": "Tag status code",
              "description": "Whether to send the status code as a metric or not.\n\nSee: https://www.krakend.io/docs/telemetry/prometheus/",
              "default": false,
              "type": "boolean"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "stackdriver": {
          "title": "Stackdriver",
          "description": "Export metrics and traces to Google Cloud",
          "type": "object",
          "required": [ "project_id", "default_labels" ],
          "properties": {
            "default_labels": {
              "title": "Default_labels",
              "description": "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.\n\nSee: https://www.krakend.io/docs/telemetry/stackdriver/",
              "examples": [
                {
                  "env": "production"
                }
              ],
              "type": "object"
            },
            "metric_prefix": {
              "title": "Metric_prefix",
              "description": "A prefix that you can add to all your metrics for better organization.\n\nSee: https://www.krakend.io/docs/telemetry/stackdriver/",
              "type": "string"
            },
            "project_id": {
              "title": "Project_id",
              "description": "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.\n\nSee: https://www.krakend.io/docs/telemetry/stackdriver/",
              "examples": [ "ID" ],
              "default": "",
              "type": "string",
              "pattern": "^.*$"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "xray": {
          "title": "AWS X-ray",
          "description": "AWS X-Ray is a service offered by Amazon that provides an end-to-end view of requests as they travel through your application, and shows a map of your application's underlying components.",
          "type": "object",
          "oneOf": [
            {
              "required": [
                "region",
                "version",
                "access_key_id",
                "secret_access_key"
              ]
            },
            {
              "required": [ "region", "version", "use_env" ]
            }
          ],
          "required": [ "region", "version" ],
          "properties": {
            "access_key_id": {
              "title": "AWS access key id",
              "description": "Your access key ID provided by Amazon. Needed when `use_env` is unset or set to false.\n\nSee: https://www.krakend.io/docs/telemetry/xray/",
              "type": "string"
            },
            "region": {
              "title": "Region",
              "description": "The AWS geographical region, e.g, `us-east-1`.\n\nSee: https://www.krakend.io/docs/telemetry/xray/",
              "examples": [ "eu-west-1" ],
              "type": "string"
            },
            "secret_access_key": {
              "title": "AWS secret access key",
              "description": "Your secret access key provided by Amazon. Needed when `use_env` is unset or set to false.\n\nSee: https://www.krakend.io",
              "type": "string"
            },
            "use_env": {
              "title": "Use_env",
              "description": "When true the AWS credentials (access_key_id and secret_access_key) are taken from environment vars. Don't specify them then.\n\nSee: https://www.krakend.io/docs/telemetry/xray/",
              "default": false,
              "type": "boolean"
            },
            "version": {
              "title": "Version",
              "description": "The version of the AWS X-Ray service to use.\n\nSee: https://www.krakend.io/docs/telemetry/xray/",
              "default": "KrakenD-opencensus",
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        },
        "zipkin": {
          "title": "Zipkin",
          "description": "Export telemetry data to a Zipkin collector",
          "type": "object",
          "required": [ "collector_url", "service_name" ],
          "properties": {
            "collector_url": {
              "title": "Collector URL",
              "description": "The URL (including port and path) where your Zipkin is accepting the spans, e.g., `http://zipkin:9411/api/v2/spans`\n\nSee: https://www.krakend.io/docs/telemetry/zipkin/",
              "examples": [ "http://192.168.99.100:9411/api/v2/spans" ],
              "type": "string"
            },
            "service_name": {
              "title": "Service name",
              "description": "The service name registered in Zipkin.\n\nSee: https://www.krakend.io/docs/telemetry/zipkin/",
              "examples": [ "krakend" ],
              "type": "string"
            }
          },
          "patternProperties": {
            "^[@$_#]": true
          },
          "additionalProperties": false
        }
      },
      "patternProperties": {
        "^[@$_#]": true
      },
      "additionalProperties": false
    },
    "reporting_period": {
      "title": "Reporting period",
      "description": "The number of seconds passing between reports. If duration is less than or equal to zero, it enables the default behavior of each exporter.\n\nSee: https://www.krakend.io/docs/telemetry/opencensus/",
      "default": 0,
      "type": "integer"
    },
    "sample_rate": {
      "title": "Sample rate",
      "description": "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.\n\nSee: https://www.krakend.io/docs/telemetry/opencensus/",
      "default": 0,
      "type": "integer",
      "maximum": 100,
      "minimum": 0
    }
  },
  "patternProperties": {
    "^[@$_#]": true
  },
  "additionalProperties": false
}
