{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.krakend.io/schema/v2.11/telemetry/opentelemetry.json",
  "title": "OpenTelemetry",
  "description": "Enables metrics and traces using OpenTelemetry.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
  "type": "object",
  "required": [ "exporters" ],
  "properties": {
    "deploy_env": {
      "title": "Deploy Environment",
      "description": "The environment you are deploying, this can be useful for deployment tracking. The string can have any value that makes sense to you to identify the running environment.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "examples": [ "development", "testing", "staging", "production" ],
      "default": "",
      "type": "string"
    },
    "exporters": {
      "title": "Exporters",
      "description": "The places where you will send telemetry data. You can declare multiple exporters even when they are of the same type. For instance, when you have a self-hosted Grafana and would like to migrate to its cloud version and check the double reporting during the transition. There are two families of exporters: `otlp` or `prometheus`.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "type": "object",
      "minProperties": 1,
      "properties": {
        "otlp": {
          "title": "OTLP exporters",
          "description": "The list of OTLP exporters you want to use. Set at least one object to push metrics and traces to an external collector using OTLP.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "type": "array",
          "minItems": 1,
          "items": {
            "required": [ "name", "host" ],
            "properties": {
              "custom_metric_reporting_period": {
                "title": "Custom metric reporting period",
                "description": "Whether you want to override the global `metric_reporting_period` attribute set for all exporters or not. Value in seconds. A missing attribute, or set to `0` means using whatever value was used in `metric_reporting_period` at the global level.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": 0,
                "type": "integer"
              },
              "disable_metrics": {
                "title": "Disable metrics",
                "description": "Disable metrics in this exporter (leaving only traces if any). It won't report any metrics when the flag is `true`.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": false,
                "type": "boolean"
              },
              "disable_traces": {
                "title": "Disable traces",
                "description": "Disable traces in this exporter (leaving only metrics if any). It won't report any metrics when the flag is `true`.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": false,
                "type": "boolean"
              },
              "host": {
                "title": "Host",
                "description": "The host where you want to push the data. It can be a sidecar or a remote collector.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "type": "string"
              },
              "name": {
                "title": "Name",
                "description": "A unique name to identify this exporter.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "examples": [ "local_prometheus", "remote_grafana" ],
                "type": "string"
              },
              "port": {
                "title": "Port",
                "description": "A custom port to send the data. The port defaults to 4317 for gRPC unless you enable `use_http`, which defaults to 4318.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": 4317,
                "type": "integer",
                "maximum": 65535,
                "minimum": 0
              },
              "use_http": {
                "title": "Use HTTP",
                "description": "Whether this exporter uses HTTP instead of gRPC.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "type": "boolean"
              }
            },
            "patternProperties": {
              "^[@$_#]": {}
            },
            "additionalProperties": false
          }
        },
        "prometheus": {
          "title": "Prometheus exporter",
          "description": "Set here at least the settings for one Prometheus exporter. Each exporter will start a local port that offers metrics to be pulled from KrakenD.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "type": "array",
          "minItems": 1,
          "items": {
            "required": [ "name" ],
            "properties": {
              "custom_metric_reporting_period": {
                "title": "Custom metric reporting period",
                "description": "Whether you want to override the global `metric_reporting_period` attribute set for all exporters or not. Value in seconds. A missing attribute, or set to `0` means using whatever value was used in `metric_reporting_period` at the global level.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": 0,
                "type": "integer"
              },
              "disable_metrics": {
                "title": "Disable metrics",
                "description": "Leave this exporter declared but disabled (useful in development). It won't report any metrics when the flag is `true`.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": false,
                "type": "boolean"
              },
              "go_metrics": {
                "title": "Go Metrics",
                "description": "Whether you want fine-grained details of Go language metrics or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "type": "boolean"
              },
              "listen_ip": {
                "title": "Listen IP",
                "description": "The IP address that KrakenD listens to in IPv4 or IPv6. You can, for instance, expose the Prometheus metrics only in a private IP address. An empty string, or no declaration means listening on all interfaces. The inclusion of `::` is intended for IPv6 format only (**this is not the port**). Examples of valid addresses are `192.0.2.1` (IPv4), `2001:db8::68` (IPv6). The values `::` and `0.0.0.0` listen to all addresses, which are valid for IPv4 and IPv6 simultaneously.",
                "examples": [ "172.12.1.1", "::1" ],
                "default": "0.0.0.0",
                "type": "string"
              },
              "name": {
                "title": "Name",
                "description": "A unique name to identify this exporter.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "examples": [ "local_prometheus", "remote_grafana" ],
                "type": "string"
              },
              "port": {
                "title": "Port",
                "description": "The port in KrakenD where Prometheus will connect to.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "default": 9090,
                "type": "integer",
                "maximum": 65535,
                "minimum": 0
              },
              "process_metrics": {
                "title": "Process Metrics",
                "description": "Whether this exporter shows detailed metrics about the running process like CPU or memory usage or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                "type": "boolean"
              }
            },
            "patternProperties": {
              "^[@$_#]": {}
            },
            "additionalProperties": false
          }
        }
      },
      "patternProperties": {
        "^[@$_#]": {}
      },
      "additionalProperties": false
    },
    "histograms": {
      "title": "Histograms",
      "description": "Use an histogram bucket configuration different from the defaults to define the detail of histogram metrics (decrease or increase their size). You don't need to set this attribute unless you want full control of the histogram definition.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "type": "object",
      "properties": {
        "size_buckets": {
          "title": "Size buckets",
          "description": "The size of the buckets in bytes you want to use for the histograms.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "default": [
            128,
            256,
            512,
            1024,
            4096,
            8192,
            16384,
            32768,
            65536,
            262144,
            524288,
            1048576,
            4194304,
            16777216,
            67108864
          ],
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "time_buckets": {
          "title": "Time buckets",
          "description": "The duration of buckets in seconds you want to use for the histograms.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "default": [
            0.01,
            0.02,
            0.05,
            0.075,
            0.1,
            0.125,
            0.15,
            0.175,
            0.2,
            0.25,
            0.3,
            0.35,
            0.5,
            0.75,
            1.0,
            1.5,
            2.0,
            3.5,
            5.0,
            10.0
          ],
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "patternProperties": {
        "^[@$_#]": {}
      },
      "additionalProperties": false
    },
    "layers": {
      "title": "Layers",
      "description": "A request and response flow passes through three different layers. This attribute lets you specify what data you want to export in each layer. All layers are enabled by default unless you declare this section.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "type": "object",
      "properties": {
        "backend": {
          "title": "Report backend activity",
          "description": "Reports the activity between KrakenD and each of your backend services. This is the more granular layer.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "type": "object",
          "properties": {
            "metrics": {
              "type": "object",
              "properties": {
                "detailed_connection": {
                  "title": "Detailed HTTP connection metrics",
                  "description": "Whether you want to enable detailed metrics for the HTTP connection phase or not. Includes times to connect, DNS querying, and the TLS handshake.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "disable_stage": {
                  "title": "Disable this stage",
                  "description": "Whether to turn off the metrics or not. Setting this to `true` means stop reporting any data.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "read_payload": {
                  "title": "Detailed payload read",
                  "description": "Whether you want to enable metrics for the response reading payload or not (HTTP connection not taken into account).\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "round_trip": {
                  "title": "Detailed Round Trip",
                  "description": "Whether you want to enable metrics for the actual HTTP request for the backend or not (manipulation not taken into account). This is the time your backend needs to produce a result.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "static_attributes": {
                  "title": "Static attributes",
                  "description": "A list of tags or labels you want to associate with these metrics.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "examples": [
                    [
                      {
                        "key": "my_metric_attr",
                        "value": "my_metric_val"
                      }
                    ]
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [ "key", "value" ],
                    "properties": {
                      "key": {
                        "title": "Key",
                        "description": "The key, tag, or label name you want to use.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                        "type": "string"
                      },
                      "value": {
                        "title": "Value",
                        "description": "The static value you want to assign to this key.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                        "type": "string"
                      }
                    },
                    "patternProperties": {
                      "^[@$_#]": {}
                    },
                    "additionalProperties": false
                  }
                }
              },
              "patternProperties": {
                "^[@$_#]": {}
              },
              "additionalProperties": false
            },
            "traces": {
              "type": "object",
              "properties": {
                "detailed_connection": {
                  "title": "Detailed HTTP connection",
                  "description": "Whether you want to add detailed trace attributes for the HTTP connection phase or not. Includes times to connect, DNS querying, and the TLS handshake.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "disable_stage": {
                  "title": "Disable this stage",
                  "description": "Whether to turn off the traces or not. Setting this to `true` means stop reporting any data.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "read_payload": {
                  "title": "Detailed payload read",
                  "description": "Whether you want to add trace attributes for the response reading payload or not (HTTP connection not taken into account).\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "report_headers": {
                  "title": "Report headers",
                  "description": "Whether you want to report the final headers that reached the backend.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "round_trip": {
                  "title": "Detailed Round Trip",
                  "description": "Whether you want to add trace attributes for the actual HTTP request for the backend or not (manipulation not taken into account). This is the time your backend needs to produce a result.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "default": false,
                  "type": "boolean"
                },
                "skip_headers": {
                  "title": "Skip headers",
                  "description": "A list of headers you want to skip when reporting the headers that reached the backend. This is useful to avoid reporting sensitive data.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "examples": [
                    [ "X-Backend-Secret", "X-All-Secret" ]
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "static_attributes": {
                  "title": "Static attributes",
                  "description": "A list of tags or labels you want to associate to these traces.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                  "examples": [
                    [
                      {
                        "key": "my_trace_attr",
                        "value": "my_trace_val"
                      }
                    ]
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [ "key", "value" ],
                    "properties": {
                      "key": {
                        "title": "Key",
                        "description": "The key, tag, or label name you want to use.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                        "type": "string"
                      },
                      "value": {
                        "title": "Value",
                        "description": "The static value you want to assign to this key.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
                        "type": "string"
                      }
                    },
                    "patternProperties": {
                      "^[@$_#]": {}
                    },
                    "additionalProperties": false
                  }
                }
              },
              "patternProperties": {
                "^[@$_#]": {}
              },
              "additionalProperties": false
            }
          },
          "patternProperties": {
            "^[@$_#]": {}
          },
          "additionalProperties": false
        },
        "global": {
          "title": "Report global activity",
          "description": "Reports the activity between end-users and KrakenD\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "type": "object",
          "properties": {
            "disable_metrics": {
              "title": "Disable global metrics",
              "description": "Whether you want to disable all metrics happening in the global layer or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "disable_propagation": {
              "title": "Disable propagation",
              "description": "Whether you want to ignore previous propagation headers to KrakenD. When the flag is set to `true`, spans from a previous layer will never be linked to the KrakenD trace.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "disable_traces": {
              "title": "Disable global trace",
              "description": "Whether you want to disable all traces happening in the global layer or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "metrics_static_attributes": {
              "title": "Static attributes",
              "description": "Static attributes you want to pass for metrics.",
              "type": "array",
              "items": {
                "properties": {
                  "key": {
                    "title": "Key",
                    "description": "The key of the static attribute you want to send",
                    "type": "string"
                  },
                  "value": {
                    "title": "Value",
                    "description": "The value of the static attribute you want to send",
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            },
            "report_headers": {
              "title": "Report headers",
              "description": "Whether you want to send all headers that the consumer passed in the request or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "semantic_convention": {
              "title": "Semantic convention naming",
              "description": "The semantic convention naming you want to use. The default is an empty string which uses the original naming convention prior to 1.27. For the semantic convention of 1.27 and higher, use `1.27`\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "enum": [ "", "1.27" ]
            },
            "traces_static_attributes": {
              "title": "Static attributes",
              "description": "Static attributes you want to pass for traces.",
              "type": "array",
              "items": {
                "properties": {
                  "key": {
                    "title": "Key",
                    "description": "The key of the static attribute you want to send",
                    "type": "string"
                  },
                  "value": {
                    "title": "Value",
                    "description": "The value of the static attribute you want to send",
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          },
          "patternProperties": {
            "^[@$_#]": {}
          },
          "additionalProperties": false
        },
        "proxy": {
          "title": "Report proxy activity",
          "description": "Reports the activity at the beginning of the proxy layer, including spawning the required requests to multiple backends, merging, endpoint transformation and any other internals of the proxy between the request processing and the backend communication\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
          "type": "object",
          "properties": {
            "disable_metrics": {
              "title": "Disable proxy metrics",
              "description": "Whether you want to disable all metrics happening in the proxy layer or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "disable_traces": {
              "title": "Disable proxy trace",
              "description": "Whether you want to disable all traces happening in the proxy layer or not.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "metrics_static_attributes": {
              "title": "Static attributes",
              "description": "Static attributes you want to pass for metrics.",
              "type": "array",
              "items": {
                "properties": {
                  "key": {
                    "title": "Key",
                    "description": "The key of the static attribute you want to send",
                    "type": "string"
                  },
                  "value": {
                    "title": "Value",
                    "description": "The value of the static attribute you want to send",
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            },
            "report_headers": {
              "title": "Report headers",
              "description": "Whether you want to report all headers that passed from the request to the proxy layer (`input_headers` policy in the endpoint plus KrakenD's headers).\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
              "default": false,
              "type": "boolean"
            },
            "traces_static_attributes": {
              "title": "Static attributes",
              "description": "Static attributes you want to pass for traces.",
              "type": "array",
              "items": {
                "properties": {
                  "key": {
                    "title": "Key",
                    "description": "The key of the static attribute you want to send",
                    "type": "string"
                  },
                  "value": {
                    "title": "Value",
                    "description": "The value of the static attribute you want to send",
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          },
          "patternProperties": {
            "^[@$_#]": {}
          },
          "additionalProperties": false
        }
      },
      "patternProperties": {
        "^[@$_#]": {}
      },
      "additionalProperties": false
    },
    "metric_reporting_period": {
      "title": "Reporting period",
      "description": "How often you want to report and flush the metrics in seconds. This setting is only used by `otlp` exporters.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "default": 30,
      "type": "integer"
    },
    "service_name": {
      "title": "Service Name",
      "description": "A friendly name identifying metrics reported by this installation. When unset, it uses the `name` attribute in the root level of the configuration.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "type": "string"
    },
    "service_version": {
      "title": "Service Version",
      "description": "The version you are deploying, this can be useful for deployment tracking.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "type": "string"
    },
    "skip_paths": {
      "title": "Skip Paths",
      "description": "The paths you don't want to report. Use the literal value used in the `endpoint` definition, including any `{placeholders}`. In the `global` layer, this attribute works only on metrics, because traces are initiated before there is an endpoint to match against. If you do not want any path skipped, just add an array with an empty string `[\"\"]`.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "examples": [ "/foo/{bar}" ],
      "default": [ "/__health", "/__debug/", "/__echo/", "/__stats/" ],
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "trace_sample_rate": {
      "title": "Trace sample rate",
      "description": "The sample rate for traces defines the percentage of reported traces. This option is key to reduce the amount of data generated (and resource usage), while you still can debug and troubleshoot issues. For instance, a number of `0.25` will report a 25% of the traces seen in the system.\n\nSee: https://www.krakend.io/docs/telemetry/opentelemetry/",
      "examples": [ 0.25 ],
      "default": 1,
      "type": "number",
      "maximum": 1,
      "minimum": 0
    }
  },
  "patternProperties": {
    "^[@$_#]": {}
  },
  "additionalProperties": false
}
