菜单
文档breadcrumb arrow Grafana Alloybreadcrumb arrow 参考breadcrumb arrow 组件breadcrumb arrow otelcolbreadcrumb arrow otelcol.connector.host_info
开源

otelcol.connector.host_info

otel.connector.host_info 接受来自其他 otelcol 组件的跟踪数据,并生成使用量指标。

用法

alloy
otelcol.connector.host_info "LABEL" {
  output {
    metrics = [...]
  }
}

参数

otelcol.connector.host_info 支持以下参数

名称类型描述默认值必需
host_identifierslist(string)用于识别唯一主机的资源属性有序列表。["host.id"]
metrics_flush_intervalduration生成指标的刷新频率。"60s"

otelcol.connector.host_info 的定义中支持以下块

层级描述必需
outputoutput配置接收到的遥测数据发送到何处。
debug_metricsdebug_metrics配置此组件生成的用于监控其状态的指标。

output 块

output 块配置一组组件来转发生成的遥测数据。

支持以下参数

名称类型描述默认值必需
metricslist(otelcol.Consumer)发送指标的消费者列表。[]

你必须指定 output 块,但其所有参数都是可选的。默认情况下,遥测数据会被丢弃。相应地配置 metrics 参数以将遥测数据发送到其他组件。

debug_metrics 块

debug_metrics 块配置此组件生成的用于监控其状态的指标。

支持以下参数

名称类型描述默认值必需
disable_high_cardinality_metricsboolean是否禁用某些高基数指标。true

disable_high_cardinality_metrics 在 Grafana Alloy 中等同于 OpenTelemetry Collector 中的 telemetry.disableHighCardinalityMetrics 功能开关。它会移除可能导致高基数指标的属性。例如,关于 HTTP 和 gRPC 连接指标中包含 IP 地址和端口号的属性将被移除。

注意

如果配置了 disable_high_cardinality_metrics,它仅适用于 otelcol.exporter.*otelcol.receiver.* 组件。

导出的字段

以下字段被导出,可以被其他组件引用

名称类型描述
inputotelcol.Consumer其他组件可用于发送遥测数据的值。

input 接受 otelcol.Consumer 跟踪遥测数据。它不接受指标和日志。

示例

以下示例接受跟踪数据,通过 otelcol.processor.resourcedetection 组件添加 host.id 资源属性,从这些跟踪数据创建使用量指标,并将指标写入 Mimir。

alloy
otelcol.receiver.otlp "otlp" {
  http {}
  grpc {}

  output {
    traces = [otelcol.processor.resourcedetection.otlp_resources.input]
  }
}

otelcol.processor.resourcedetection "otlp_resources" {
  detectors = ["system"]
  system {
    hostname_sources = [ "os" ]
    resource_attributes {
      host.id {
        enabled = true
      }
    }
  }
  output {
    traces = [otelcol.connector.host_info.default.input]
  }
}

otelcol.connector.host_info "default" {
  output {
    metrics = [otelcol.exporter.prometheus.otlp_metrics.input]
  }
}

otelcol.exporter.prometheus "otlp_metrics" {
  forward_to = [prometheus.remote_write.default.receiver]
}

prometheus.remote_write "default" {
  endpoint {
    url = "https://prometheus-xxx.grafana.net/api/prom/push"
    basic_auth {
      username = sys.env("PROMETHEUS_USERNAME")
      password = sys.env("GRAFANA_CLOUD_API_KEY")
    }
  }
}

兼容组件

otelcol.connector.host_info 可以接受来自以下组件的参数

otelcol.connector.host_info 具有可被以下组件消费的导出项

注意

连接某些组件可能不合理,或者组件可能需要进一步配置才能使连接正常工作。请参考链接的文档了解更多详情。