Skip to content

Commit bbb3a62

Browse files
authored
Merge pull request #157 from lomik/rework-config
Rework configuration package
2 parents fa36c3f + da75e2c commit bbb3a62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6547
-429
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ jobs:
3838
git fetch --shallow-since=$(git log $VERS -1 --format=%at)
3939
if: ${{ github.event_name == 'push' }}
4040

41-
- name: Test
41+
- name: Build project
42+
run: make
43+
44+
- name: Check documentation consistency
4245
run: |
43-
make
44-
make test
46+
make config
47+
git diff --exit-code
48+
49+
- name: Test
50+
run: make test
4551

4652
- name: Install packaging dependencies
4753
run: |

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,28 @@ all: $(NAME)
1919

2020
.PHONY: clean
2121
clean:
22+
rm $(NAME)
2223
rm -rf out
2324
rm -f *deb *rpm
2425
rm -f sha256sum md5sum
2526

26-
.PHONY: $(NAME)
27-
$(NAME):
27+
$(NAME): $(wildcard **/*.go)
2828
$(GO) build $(MODULE)
2929

30+
deploy/doc/graphite-clickhouse.conf: $(NAME)
31+
./$(NAME) -config-print-default > $@
32+
33+
doc/config.md: deploy/doc/graphite-clickhouse.conf deploy/doc/config.md
34+
@echo 'Generating $@...'
35+
@printf '[//]: # (This file is built out of deploy/doc/config.md, please do not edit it manually) \n' > $@
36+
@printf '[//]: # (To rebuild it run `make config`)\n\n' >> $@
37+
@cat deploy/doc/config.md >> $@
38+
@printf '\n```toml\n' >> $@
39+
@cat deploy/doc/graphite-clickhouse.conf >> $@
40+
@printf '```\n' >> $@
41+
42+
config: doc/config.md
43+
3044
test:
3145
$(GO) test -race ./...
3246

README.md

Lines changed: 1 addition & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -34,185 +34,7 @@ make
3434
3. Add graphite-clickhouse `host:port` to graphite-web [CLUSTER_SERVERS](http://graphite.readthedocs.io/en/latest/config-local-settings.html#cluster-configuration)
3535

3636
## Configuration
37-
Create `/etc/graphite-clickhouse/rollup.xml` with same content as for ClickHouse. Short sample:
38-
```xml
39-
<graphite_rollup>
40-
<default>
41-
<function>avg</function>
42-
<retention>
43-
<age>0</age>
44-
<precision>60</precision>
45-
</retention>
46-
<retention>
47-
<age>2592000</age>
48-
<precision>3600</precision>
49-
</retention>
50-
</default>
51-
</graphite_rollup>
52-
```
53-
54-
For complex ClickHouse queries you might need to increase default query_max_size. To do that add following line to `/etc/clickhouse-server/users.xml` for the user you are using:
55-
```xml
56-
<!-- Default is 262144 -->
57-
<max_query_size>10485760</max_query_size>
58-
```
59-
60-
Create `/etc/graphite-clickhouse/graphite-clickhouse.conf`
61-
```toml
62-
[common]
63-
listen = ":9090"
64-
# Listener to serve /debug/pprof requests. `-pprof` argument would override it
65-
pprof-listen = ""
66-
max-cpu = 1
67-
# How frequently to call debug.FreeOSMemory() to return memory back to OS
68-
# Setting it to zero disables this functionality
69-
memory-return-interval = "0s"
70-
# Limit number of results from find query. Zero = unlimited
71-
max-metrics-in-find-answer = 0
72-
# Limit numbers of queried metrics per target in /render requests. Zero or negative are unlimited
73-
max-metrics-per-target = 15000
74-
# Daemon returns empty response if query matches any of regular expressions
75-
# target-blacklist = ["^not_found.*"]
76-
# If this > 0, then once an interval daemon will return the freed memory to the OS
77-
memory-return-interval = "0s"
78-
79-
[clickhouse]
80-
# You can add user/password (http://user:password@localhost:8123) and any clickhouse options (GET-parameters) to url
81-
# It is recommended to create read-only user
82-
url = "http://localhost:8123"
83-
# Add extra prefix (directory in graphite) for all metrics
84-
extra-prefix = ""
85-
86-
# Default table with points
87-
data-table = "graphite"
88-
data-timeout = "1m0s"
89-
# Rollup rules xml filename. Use `auto` magic word for select rollup rules from ClickHouse
90-
rollup-conf = "/etc/graphite-clickhouse/rollup.xml"
91-
92-
# Table with series list (daily and full)
93-
# https://github.com/lomik/graphite-clickhouse/wiki/IndexTable
94-
index-table = "graphite_index"
95-
# Use daily data from index table. This is useful for installations with big count of short-lived series but can be slower in other cases
96-
index-use-daily = true
97-
# Allow use reverse queries with minimal depth
98-
# -1 - disable
99-
# 0 - disable if no wildcard at first level
100-
# 1 - allow for example a.b.c*.d and a.b*.c.d queries (default)
101-
# 2 - allow a.b*.c.d) to index table.
102-
# This is useful when reverse queries has bad perfomance
103-
index-reverse-depth = 1
104-
# overwrite default index-use-reverse for metrics with prefix/suffix/regular_expression checks against target (not used when index-use-reverse = -1)
105-
#index-reverses = [
106-
# { suffix = ".p99", reverse = 2 },
107-
# { suffix = ".avg", reverse = 2 },
108-
# { suffix = ".gc.gen1", reverse = 0 },
109-
# { prefix = "Test.", suffix = ".cpu", reverse = 2 },
110-
# { regex = "\\.gc\\.(heap|gen)[0-9]+$", reverse = 0 }
111-
#]
112-
index-reverses = []
113-
index-timeout = "1m0s"
114-
115-
# `tagged` table from carbon-clickhouse. Required for seriesByTag
116-
tagged-table = ""
117-
# For how long the daemon will query tags during autocomplete
118-
tagged-autocomplete-days = 7
119-
120-
# Old index tables. DEPRECATED
121-
tree-table = "graphite_tree"
122-
# Optional table with daily series list.
123-
# Useful for installations with big count of short-lived series
124-
date-tree-table = ""
125-
# Supported several schemas of date-tree-table:
126-
# 1 (default): table only with Path, Date, Level fields. Described here: https://habrahabr.ru/company/avito/blog/343928/
127-
# 2: table with Path, Date, Level, Deleted, Version fields. Table type "series" in the carbon-clickhouse
128-
# 3: same as #2 but with reversed Path. Table type "series-reverse" in the carbon-clickhouse
129-
date-tree-table-version = 0
130-
tree-timeout = "1m0s"
131-
132-
connect-timeout = "1s"
133-
134-
# Sets the maximum for maxDataPoints parameter.
135-
# If you use CH w/o https://github.com/ClickHouse/ClickHouse/pull/13947, you have to set it to 4096
136-
max-data-points = 4096
137-
# Use metrics aggregation on ClickHouse site.
138-
# This feature is very useful, read https://github.com/lomik/graphite-clickhouse/wiki/ClickHouse-aggregation-VS-graphite%E2%80%94clickhouse-aggregation
139-
internal-aggregation = false
140-
141-
[prometheus]
142-
# The URL under which Prometheus is externally reachable (for example, if Prometheus is served via a reverse proxy). Used for
143-
# generating relative and absolute links back to Prometheus itself. If the URL has a path portion, it will be used to prefix all
144-
# HTTP endpoints served by Prometheus. If omitted, relevant URL components will be derived automatically.
145-
external-url = ""
146-
page-title = "Prometheus Time Series Collection and Processing Server"
147-
148-
[carbonlink]
149-
server = ""
150-
threads-per-request = 10
151-
connect-timeout = "50ms"
152-
query-timeout = "50ms"
153-
total-timeout = "500ms"
154-
155-
# You can define multiple data tables (with points).
156-
# The first table that matches is used.
157-
#
158-
# # Sample, archived table with points older 30d
159-
# [[data-table]]
160-
# table = "graphite_archive"
161-
# min-age = "720h"
162-
#
163-
# # All available options
164-
# [[data-table]]
165-
# # clickhouse table name
166-
# table = "table_name"
167-
# # points in table are stored with reverse path
168-
# reverse = false
169-
# # Custom rollup.xml for table.
170-
# # Magic word `auto` can be used for load rules from ClickHouse
171-
# # With value `none` only rollup-default-precision and rollup-default-function will be used for rollup
172-
# rollup-conf = ""
173-
# # Which table to discover rollup-rules from. If not specified - will use what specified in "table" parameter.
174-
# # Useful when reading from distributed table, but the rollup parameters are on the shard tables.
175-
# # Can be in "database.table" form.
176-
# rollup-auto-table = ""
177-
# # Use unreversed metric name to discover rollup-rules. If not specified - use as is (reversed metric name).
178-
# # Use if unreversed rules is used.
179-
# # Ignored for non-reverse tables (unreversed metric names used always)
180-
# rollup-use-reverted = false
181-
# # Sets the default precision and function for rollup patterns which don't have age=0 retention defined.
182-
# # If age=0 retention is defined in the rollup config then it takes precedence.
183-
# # If left at the default value of 0 then no rollup is performed when the requested interval
184-
# # is not covered by any rollup rule. In this case the points will be served with 60 second precision.
185-
# rollup-default-precision = 60
186-
# rollup-default-function = "avg"
187-
# # from >= now - {max-age}
188-
# max-age = "240h"
189-
# # until <= now - {min-age}
190-
# min-age = "240h"
191-
# # until - from <= {max-interval}
192-
# max-interval = "24h"
193-
# # until - from >= {min-interval}
194-
# min-interval = "24h"
195-
# # regexp.Match({target-match-any}, target[0]) || regexp.Match({target-match-any}, target[1]) || ...
196-
# target-match-any = "regexp"
197-
# # regexp.Match({target-match-all}, target[0]) && regexp.Match({target-match-all}, target[1]) && ...
198-
# target-match-all = "regexp"
199-
200-
[debug]
201-
# The directory for debug info. If set, additional info may be saved there
202-
directory = "/var/log/graphite-clickhouse/debug"
203-
directory-perm = "0755"
204-
# File permissions for external data dumps. Enabled only if !=0, see X-Gch-Debug-External-Data header
205-
# Format is octal, e.g. 0640
206-
external-data-perm = "0644"
207-
208-
[[logging]]
209-
logger = ""
210-
file = "/var/log/graphite-clickhouse/graphite-clickhouse.log"
211-
level = "info"
212-
encoding = "mixed"
213-
encoding-time = "iso8601"
214-
encoding-duration = "seconds"
215-
```
37+
See [configuration documentation](./doc/config.md).
21638

21739
### Special headers processing
21840

autocomplete/autocomplete.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ func (h *Handler) ServeTags(w http.ResponseWriter, r *http.Request) {
142142

143143
body, err := clickhouse.Query(
144144
scope.WithTable(r.Context(), h.config.ClickHouse.TaggedTable),
145-
h.config.ClickHouse.Url,
145+
h.config.ClickHouse.URL,
146146
sql,
147147
clickhouse.Options{
148-
Timeout: h.config.ClickHouse.TreeTimeout.Value(),
149-
ConnectTimeout: h.config.ClickHouse.ConnectTimeout.Value(),
148+
Timeout: h.config.ClickHouse.IndexTimeout,
149+
ConnectTimeout: h.config.ClickHouse.ConnectTimeout,
150150
},
151151
nil,
152152
)
@@ -248,11 +248,11 @@ func (h *Handler) ServeValues(w http.ResponseWriter, r *http.Request) {
248248

249249
body, err := clickhouse.Query(
250250
scope.WithTable(r.Context(), h.config.ClickHouse.TaggedTable),
251-
h.config.ClickHouse.Url,
251+
h.config.ClickHouse.URL,
252252
sql,
253253
clickhouse.Options{
254-
Timeout: h.config.ClickHouse.IndexTimeout.Value(),
255-
ConnectTimeout: h.config.ClickHouse.ConnectTimeout.Value(),
254+
Timeout: h.config.ClickHouse.IndexTimeout,
255+
ConnectTimeout: h.config.ClickHouse.ConnectTimeout,
256256
},
257257
nil,
258258
)

config/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests_tmp/

0 commit comments

Comments
 (0)