项目作者: lomik

项目描述 :
Graphite metrics receiver with ClickHouse as storage
高级语言: Go
项目地址: git://github.com/lomik/carbon-clickhouse.git
创建时间: 2016-11-02T18:10:37Z
项目社区:https://github.com/lomik/carbon-clickhouse

开源协议:MIT License

下载


deb
rpm

carbon-clickhouse

Graphite metrics receiver with ClickHouse as storage

Production status

Last releases are stable and ready for production use

TL;DR

Preconfigured docker-compose

Docker

Docker images are available on packages page.

Build

Required golang 1.23+

  1. # build binary
  2. git clone https://github.com/lomik/carbon-clickhouse.git
  3. cd carbon-clickhouse
  4. make

ClickHouse configuration

  1. Add graphite_rollup section to config.xml. Sample here. You can use carbon-schema-to-clickhouse for generate rollup xml from graphite storage-schemas.conf.

  2. Create tables.

  1. CREATE TABLE graphite (
  2. Path String,
  3. Value Float64,
  4. Time UInt32,
  5. Date Date,
  6. Timestamp UInt32
  7. ) ENGINE = GraphiteMergeTree('graphite_rollup')
  8. PARTITION BY toYYYYMM(Date)
  9. ORDER BY (Path, Time);
  10. -- optional table for faster metric search
  11. CREATE TABLE graphite_index (
  12. Date Date,
  13. Level UInt32,
  14. Path String,
  15. Version UInt32
  16. ) ENGINE = ReplacingMergeTree(Version)
  17. PARTITION BY toYYYYMM(Date)
  18. ORDER BY (Level, Path, Date);
  19. -- optional table for storing Graphite tags
  20. CREATE TABLE graphite_tagged (
  21. Date Date,
  22. Tag1 String,
  23. Path String,
  24. Tags Array(String),
  25. Version UInt32
  26. ) ENGINE = ReplacingMergeTree(Version)
  27. PARTITION BY toYYYYMM(Date)
  28. ORDER BY (Tag1, Path, Date);

GraphiteMergeTree documentation

You can create Replicated tables. See ClickHouse documentation

Configuration

  1. $ carbon-clickhouse -help
  2. Usage of carbon-clickhouse:
  3. -check-config=false: Check config and exit
  4. -config="": Filename of config
  5. -config-print-default=false: Print default config
  6. -version=false: Print version

Date are broken by default (not always in UTC), but this used from start of project, and can produce some bugs.
Change to UTC requires points/index/tags tables rebuild (Date recalc to true UTC) or queries with wide Date range.
Set data.utc-date = true for this.
Without UTC date is required to run carbon-clickhouse and graphite-clickhouse in one timezone.

  1. [common]
  2. # Prefix for store all internal carbon-clickhouse graphs. Supported macroses: {host}
  3. metric-prefix = "carbon.agents.{host}"
  4. # Endpoint for store internal carbon metrics. Valid values: "" or "local", "tcp://host:port", "udp://host:port"
  5. metric-endpoint = "local"
  6. # Interval of storing internal metrics. Like CARBON_METRIC_INTERVAL
  7. metric-interval = "1m0s"
  8. # GOMAXPROCS
  9. max-cpu = 1
  10. [logging]
  11. # "stderr", "stdout" can be used as file name
  12. file = "/var/log/carbon-clickhouse/carbon-clickhouse.log"
  13. # Logging error level. Valid values: "debug", "info", "warn" "error"
  14. level = "info"
  15. [data]
  16. # Folder for buffering received data
  17. path = "/data/carbon-clickhouse/"
  18. # Rotate (and upload) file iniciated on size and interval
  19. # Rotate (and upload) file size (in bytes, also k, m and g units can be used)
  20. # chunk-max-size = '512m'
  21. chunk-max-size = 0
  22. # Rotate (and upload) file interval
  23. # Minimize chunk-interval for minimize lag between point receive and store
  24. chunk-interval = "1s"
  25. # Auto-increase chunk interval if the number of unprocessed files is grown
  26. # Sample, set chunk interval to 10 if unhandled files count >= 5 and set to 60s if unhandled files count >= 20:
  27. # chunk-auto-interval = "5:10s,20:60s"
  28. chunk-auto-interval = ""
  29. # Compression algorithm to use when storing temporary files.
  30. # Might be useful to reduce space usage when Clickhouse is unavailable for an extended period of time.
  31. # Currently supported: none, lz4
  32. compression = "none"
  33. # Compression level to use.
  34. # For "lz4" 0 means use normal LZ4, >=1 use LZ4HC with this depth (the higher - the better compression, but slower)
  35. compression-level = 0
  36. # Date are broken by default (not always in UTC)
  37. #utc-date = false
  38. [upload.graphite]
  39. type = "points"
  40. table = "graphite"
  41. threads = 1
  42. url = "http://localhost:8123/"
  43. # compress-data enables gzip compression while sending to clickhouse
  44. compress-data = true
  45. timeout = "1m0s"
  46. # save zero value to Timestamp column (for point and posts-reverse tables)
  47. zero-timestamp = false
  48. [upload.graphite_index]
  49. type = "index"
  50. table = "graphite_index"
  51. threads = 1
  52. url = "http://localhost:8123/"
  53. timeout = "1m0s"
  54. cache-ttl = "12h0m0s"
  55. # Store hash of metric in memory instead of full metric name
  56. # Allowed values: "", "city64" (empty value - disabled)
  57. hash = ""
  58. # If daily index should be disabled, default is `false`
  59. disable-daily-index = false
  60. # # You can define additional upload destinations of any supported type:
  61. # # - points
  62. # # - index
  63. # # - tagged (is described below)
  64. # # - points-reverse (same scheme as points, but path 'a1.b2.c3' stored as 'c3.b2.a1')
  65. # # For uploaders with types "points" and "points-reverse" there is a possibility to ignore data using patterns. E.g.
  66. # [upload.graphite]
  67. # type = "graphite"
  68. # table = "graphite.points"
  69. # threads = 1
  70. # url = "http://localhost:8123/"
  71. # timeout = "30s"
  72. # ignored-patterns = [
  73. # "a1.b2.*.c3",
  74. # ]
  75. # # Extra table which can be used as index for tagged series
  76. # # Also, there is an opportunity to avoid writing tags for some metrics.
  77. # # Example below, ignored-tagged-metrics.
  78. # [upload.graphite_tagged]
  79. # type = "tagged"
  80. # table = "graphite_tagged"
  81. # threads = 1
  82. # url = "http://localhost:8123/"
  83. # timeout = "1m0s"
  84. # cache-ttl = "12h0m0s"
  85. # ignored-tagged-metrics = [
  86. # "a.b.c.d", # all tags (but __name__) will be ignored for metrics like a.b.c.d?tagName1=tagValue1&tagName2=tagValue2...
  87. # "*", # all tags (but __name__) will be ignored for all metrics; this is the only special case with wildcards
  88. # ]
  89. #
  90. # It is possible to connect to clickhouse with OpenSSL certificates (mTLS) like below:
  91. # [upload.graphite]
  92. # type = "points"
  93. # table = "graphite"
  94. # threads = 1
  95. # compress-data = true
  96. # zero-timestamp = false
  97. # timeout = "1m0s"
  98. # url = "https://localhost:8443/" # url is https
  99. # [upload.graphite.tls]
  100. # ca-cert = [ "<path/to/rootCA.crt>", "<path/to/other/rootCA.crt>" ]
  101. # server-name = "<server-name>"
  102. # insecure-skip-verify = false # if true, server certificates will not be validated
  103. # [[upload.graphite.tls.certificates]]
  104. # key = "<path/to/client.key>"
  105. # cert = "<path/to/client.crt>"
  106. [udp]
  107. listen = ":2003"
  108. enabled = true
  109. # drop received point if timestamp > now + value. 0 - don't drop anything
  110. drop-future = "0s"
  111. # drop received point if timestamp < now - value. 0 - don't drop anything
  112. drop-past = "0s"
  113. # drop metrics with names longer than this value. 0 - don't drop anything
  114. drop-longer-than = 0
  115. [tcp]
  116. listen = ":2003"
  117. enabled = true
  118. drop-future = "0s"
  119. drop-past = "0s"
  120. drop-longer-than = 0
  121. [pickle]
  122. listen = ":2004"
  123. enabled = true
  124. drop-future = "0s"
  125. drop-past = "0s"
  126. drop-longer-than = 0
  127. # https://github.com/lomik/carbon-clickhouse/blob/master/grpc/carbon.proto
  128. [grpc]
  129. listen = ":2005"
  130. enabled = false
  131. drop-future = "0s"
  132. drop-past = "0s"
  133. drop-longer-than = 0
  134. [prometheus]
  135. listen = ":2006"
  136. enabled = false
  137. drop-future = "0s"
  138. drop-past = "0s"
  139. drop-longer-than = 0
  140. [telegraf_http_json]
  141. listen = ":2007"
  142. enabled = false
  143. drop-future = "0s"
  144. drop-past = "0s"
  145. drop-longer-than = 0
  146. # the character to join telegraf metric and field (default is "_" for historical reason and Prometheus compatibility)
  147. concat = "."
  148. # Golang pprof + some extra locations
  149. #
  150. # Last 1000 points dropped by "drop-future", "drop-past" and "drop-longer-than" rules:
  151. # /debug/receive/tcp/dropped/
  152. # /debug/receive/udp/dropped/
  153. # /debug/receive/pickle/dropped/
  154. # /debug/receive/grpc/dropped/
  155. # /debug/receive/prometheus/dropped/
  156. # /debug/receive/telegraf_http_json/dropped/
  157. [pprof]
  158. listen = "localhost:7007"
  159. enabled = false
  160. # You can use tag matching like in InfluxDB. Format is exactly the same.
  161. # It will parse all metrics that don't have tags yet.
  162. # For more information see https://docs.influxdata.com/influxdb/v1.7/supported_protocols/graphite/
  163. # Example:
  164. # [convert_to_tagged]
  165. # enabled = true
  166. # separator = "_"
  167. # tags = ["region=us-east", "zone=1c"]
  168. # templates = [
  169. # "generated.* .measurement.cpu metric=idle",
  170. # "* host.measurement* template_match=none",
  171. # ]