Receiver

参数解析

启动参数

名称默认值说明
grpc-address0.0.0.0:10901gRPC服务 StoreAPI 监听的地址
grpc-grace-period2mgRPC服务接收到停止需等待时间,通过配置 context.WithTimeout 的实现
grpc-server-max-connection-age60mTODO;
grpc-server-tls-cert""是否开启tls认证,为空表示禁用
grpc-server-tls-client-ca""TLS CA,为空表示不对客户端验证
grpc-server-tls-key""是否开启tls认证,为空表示禁用
hash-func""TODO; 如:"", “SHA256”
http-address0.0.0.0:10902监听 HTTP 服务地址
http-grace-period2mHTTP服务接收到停止需等待时间,通过配置 context.WithTimeout 的实现
http.config""TODO; http的配置,用于开启TLS、认证等
label""格式:="",植入标签,用于标识
log.formatlogfmt日志格式,可取值:logfmt、json
log.levelinfo日志级别
objstore.config""功能同 ‘objstore.config-file’ 对象存储地址
objstore.config-file""对象存储地址
receive.default-tenant-iddefault-tenant如果未设置租户ID,则以此为默认值
receive.hashrings""功能同 ‘receive.hashrings-file’,优先级高
receive.hashrings-algorithmhashmod用于 hashrings 算法,可取:hashmod, ketama
receive.hashrings-file""TODO;
receive.hashrings-file-refresh-interval5m刷新 hashrings-file 指向文件的时间
receive.local-endpoint""在hashring文件列表配置的所有地址,指明哪个为该节点,如果为空且配置了hashring则开启"RoutingOnly"模式
receive.relabel-config""功能同 ‘receive.relabel-config-file’
receive.relabel-config-file""TODO;
receive.replica-headerTHANOS-REPLICATODO; 用于表示副本数的HTTP请求头
receive.replication-factor1TODO; int((h.options.ReplicationFactor / 2) + 1)
receive.tenant-certificate-field""使用 tls 证书中的属性表示租户,必须是 organization, organizationalUnit or commonName 之一,优先级高于 receive.tenant-header
receive.tenant-headerTHANOS-TENANTHTTP请求头,值代表写入的租户
receive.tenant-label-nametenant_id植入到指标里租户的标签名
remote-write.address0.0.0.0:19291用于 remote write 的http服务地址
remote-write.client-server-name""TODO;
remote-write.client-tls-ca""用于验证客户端
remote-write.client-tls-cert""同上
remote-write.client-tls-key""同上
remote-write.server-tls-cert""用于 remote write 服务是否开启tls,为空表示关闭
remote-write.server-tls-key""同上
remote-write.server-tls-client-ca""用于验证客户端,未配置则不开启
request.logging-config""功能同 ‘request.logging-config-file’
request.logging-config-file""TODO;
tracing.config""功能同 ’tracing.config-file’
tracing.config-file""TODO;
tsdb.allow-overlapping-blocks-TODO;
tsdb.max-exemplars0TODO;
tsdb.no-lockfile""TODO;
tsdb.path./dataTODO;
tsdb.retention15d性能数据保留的时间,设置0表示不过期
tsdb.wal-compression""是否压缩 wal
  • 隐藏参数
名称默认值说明
receive-forward-timeout5s转发的超时时间
tsdb.min-block-duration2hTODO;
tsdb.max-block-duration2hTODO;
shipper.ignore-unequal-block-sizefalseTODO;
shipper.allow-out-of-order-uploadsfalseTODO;

两种模式

Routing Receiver

在启动参数不配置以下时,为该模式,仅做流量转发

--receive.local-endpoint=RECEIVE.LOCAL-ENDPOINT

该模式需明确指定--receive.hashrings-file参数。

Ingesting Receiver

在启动参数不配置以下时,为该模式,仅做数据存储

--receive.hashrings-file=<path>

该模式需明确指定--receive.local-endpoint参数。

RouterIngestor

既是Routing也是Ingesting

// determineMode returns the ReceiverMode that this receiver is configured to run in.
// This is used to configure this Receiver's forwarding and ingesting behavior at runtime.
func (rc *receiveConfig) determineMode() receive.ReceiverMode {
	// Has the user provided some kind of hashring configuration?
	hashringSpecified := rc.hashringsFileContent != "" || rc.hashringsFilePath != ""
	// Has the user specified the --receive.local-endpoint flag?
	localEndpointSpecified := rc.endpoint != ""

	switch {
	case hashringSpecified && localEndpointSpecified:
		return receive.RouterIngestor
	case hashringSpecified && !localEndpointSpecified:
		// Be careful - if the hashring contains an address that routes to itself and does not specify a local
		// endpoint - you've just created an infinite loop / fork bomb :)
		return receive.RouterOnly
	default:
		// hashring configuration has not been provided so we ingest all metrics locally.
		return receive.IngestorOnly
	}
}