如何把数据转发给多个时序库?

关键字 Pushgw.Writers

找到配置文件config.toml(./etc/config.toml)中关键字‘Pushgw.Writers’, 在toml中[[..]]是数组(table array,表数组)可以重复多个,所以这里把原有配置复制一份在后面即可实现。

  1. [[Pushgw.Writers]] #TSDB1
  2. # Url = "http://127.0.0.1:8480/insert/0/prometheus/api/v1/write"
  3. Url = "http://127.0.0.1:9090/api/v1/write"
  4. # Basic auth username
  5. BasicAuthUser = ""
  6. # Basic auth password
  7. BasicAuthPass = ""
  8. # timeout settings, unit: ms
  9. Headers = ["X-From", "n9e"]
  10. Timeout = 10000
  11. DialTimeout = 3000
  12. TLSHandshakeTimeout = 30000
  13. ExpectContinueTimeout = 1000
  14. IdleConnTimeout = 90000
  15. # time duration, unit: ms
  16. KeepAlive = 30000
  17. MaxConnsPerHost = 0
  18. MaxIdleConns = 100
  19. MaxIdleConnsPerHost = 100
  20. [[Pushgw.Writers]] #TSDB2
  21. # Url = "http://127.0.0.1:8480/insert/0/prometheus/api/v1/write"
  22. Url = "http://127.1.1.1:9191/api/v1/write"
  23. # Basic auth username
  24. BasicAuthUser = ""
  25. # Basic auth password
  26. BasicAuthPass = ""
  27. # timeout settings, unit: ms
  28. Headers = ["X-From", "n9e"]
  29. Timeout = 10000
  30. DialTimeout = 3000
  31. TLSHandshakeTimeout = 30000
  32. ExpectContinueTimeout = 1000
  33. IdleConnTimeout = 90000
  34. # time duration, unit: ms
  35. KeepAlive = 30000
  36. MaxConnsPerHost = 0
  37. MaxIdleConns = 100
  38. MaxIdleConnsPerHost = 100

💡 Toml语法可查看Toml官方文档中文文档。go库:https://github.com/BurntSushi/toml,这里是使用示例