远程可写存储

remote_write 主要用于可写远程存储配置,主要包含以下参数:

  • url: 访问地址
  • remote_timeout: 请求超时时间
  • write_relabel_configs: 标签重置配置, 拉取到的数据,经过重置处理后,发送给远程存储

其代码结构体为:

  1. // RemoteWriteConfig is the configuration for writing to remote storage.
  2. type RemoteWriteConfig struct {
  3. URL *URL `yaml:"url,omitempty"`
  4. RemoteTimeout model.Duration `yaml:"remote_timeout,omitempty"`
  5. WriteRelabelConfigs []*RelabelConfig `yaml:"write_relabel_configs,omitempty"`
  6. // We cannot do proper Go type embedding below as the parser will then parse
  7. // values arbitrarily into the overflow maps of further-down types.
  8. HTTPClientConfig HTTPClientConfig `yaml:",inline"`
  9. // Catches all undefined fields and must be empty after parsing.
  10. XXX map[string]interface{} `yaml:",inline"`
  11. }

一份完整的配置大致为:

  1. # The URL of the endpoint to send samples to.
  2. url: <string>
  3. # Timeout for requests to the remote write endpoint.
  4. [ remote_timeout: <duration> | default = 30s ]
  5. # List of remote write relabel configurations.
  6. write_relabel_configs:
  7. [ - <relabel_config> ... ]
  8. # Sets the `Authorization` header on every remote write request with the
  9. # configured username and password.
  10. basic_auth:
  11. [ username: <string> ]
  12. [ password: <string> ]
  13. # Sets the `Authorization` header on every remote write request with
  14. # the configured bearer token. It is mutually exclusive with `bearer_token_file`.
  15. [ bearer_token: <string> ]
  16. # Sets the `Authorization` header on every remote write request with the bearer token
  17. # read from the configured file. It is mutually exclusive with `bearer_token`.
  18. [ bearer_token_file: /path/to/bearer/token/file ]
  19. # Configures the remote write request's TLS settings.
  20. tls_config:
  21. [ <tls_config> ]
  22. # Optional proxy URL.
  23. [ proxy_url: <string> ]

注意: remote_write 属于试验阶段,慎用,因为在以后的版本中可能发生改变。