Skip to content

Commit f418fb0

Browse files
committed
Initial commit
1 parent c7b5b8a commit f418fb0

File tree

13 files changed

+432
-1
lines changed

13 files changed

+432
-1
lines changed

Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
FROM phusion/baseimage:0.9.22
2+
MAINTAINER Denys Zhdanov <[email protected]>
3+
4+
RUN apt-get -y update \
5+
&& apt-get -y upgrade \
6+
&& apt-get -y --force-yes install ca-certificates \
7+
apt-transport-https \
8+
wget \
9+
nginx \
10+
git \
11+
sqlite3 \
12+
libcairo2 \
13+
libcairo2-dev \
14+
&& curl -s https://packagecloud.io/install/repositories/go-graphite/stable/script.deb.sh | bash \
15+
&& apt-get install -y carbonapi carbonzipper \
16+
&& mkdir /etc/carbonapi/ \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
# install go-carbon
20+
RUN wget https://github.com/lomik/go-carbon/releases/download/v0.10.1/go-carbon_0.10.1_amd64.deb \
21+
&& dpkg -i go-carbon_0.10.1_amd64.deb \
22+
&& rm /go-carbon_0.10.1_amd64.deb \
23+
&& mkdir -p /var/lib/graphite/whisper \
24+
&& mkdir -p /var/lib/graphite/dump \
25+
&& service go-carbon stop
26+
27+
# install grafana
28+
RUN wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_4.4.1_amd64.deb \
29+
&& dpkg -i grafana_4.4.1_amd64.deb \
30+
&& rm /grafana_4.4.1_amd64.deb \
31+
&& service grafana-server restart \
32+
&& sleep 5 \
33+
&& curl -X POST -H 'Content-Type: application/json' -u 'admin:admin' \
34+
-d '{ "name": "carbonapi", "type": "graphite", "url": "https://127.0.0.1:8081", "access": "proxy", "basicAuth": false }' \
35+
"http://127.0.0.1:3000/api/datasources" \
36+
&& service grafana-server stop
37+
38+
# config nginx
39+
RUN rm /etc/nginx/sites-enabled/default
40+
ADD conf/etc/nginx/nginx.conf /etc/nginx/nginx.conf
41+
ADD conf/etc/nginx/sites-enabled/go-graphite.conf /etc/nginx/sites-enabled/go-graphite.conf
42+
43+
# config go-carbon
44+
ADD conf/etc/go-carbon/go-carbon.conf /etc/go-carbon/go-carbon.conf
45+
ADD conf/etc/go-carbon/storage-aggregation.conf /etc/go-carbon/storage-aggregation.conf
46+
ADD conf/etc/go-carbon/storage-schemas.conf /etc/go-carbon/storage-schemas.conf
47+
48+
# config carbonapi
49+
ADD conf/etc/carbonapi/carbonapi.yaml /etc/carbonapi/carbonapi.yaml
50+
51+
# logging support
52+
RUN mkdir -p /var/log/go-carbon /var/log/carbonapi /var/log/nginx
53+
ADD conf/etc/logrotate.d/go-graphite.conf /etc/logrotate.d/go-graphite.conf
54+
55+
# daemons
56+
ADD conf/etc/service/go-carbon/run /etc/service/go-carbon/run
57+
ADD conf/etc/service/carbonapi/run /etc/service/carbonapi/run
58+
ADD conf/etc/service/grafana/run /etc/service/grafana/run
59+
ADD conf/etc/service/nginx/run /etc/service/nginx/run
60+
61+
# cleanup
62+
RUN apt-get clean\
63+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
64+
65+
# defaults
66+
EXPOSE 80 2003 2004 8080 8081
67+
VOLUME ["/etc/go-carbon", "/etc/carbonapi", "/var/lib/graphite", "/etc/nginx", "/etc/logrotate.d", "/var/log"]
68+
WORKDIR /
69+
ENV HOME /root
70+
CMD ["/sbin/my_init"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# docker-go-graphite
22
Docker image for go-carbon + carbonapi + grafana (zipper included)
33

4-
WIP
4+
WIP, not ready yet

conf/etc/carbonapi/carbonapi.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Need to be URL, http or https
2+
# This url specifies the backend or a loadbalancer
3+
#
4+
# Is you are using carbonzipper you should set it to
5+
# zipper's url
6+
#
7+
# If you are using plain go-carbon or graphite-clickhouse
8+
# you should set it to URL of go-carbon's carbonserver module
9+
# or graphite-clickhouse's http url.
10+
zipper: "http://localhost:8080"
11+
# Listen address, should always include hostname or ip address and a port.
12+
listen: "localhost:8081"
13+
# Max concurrent requests to CarbonZipper
14+
concurency: 20
15+
cache:
16+
# Type of caching. Valid: "mem", "memcache", "null"
17+
type: "mem"
18+
# Cache limit in megabytes
19+
size_mb: 0
20+
# Default cache timeout value. Identical to DEFAULT_CACHE_DURATION in graphite-web.
21+
defaultTimeoutSec: 60
22+
# Only used by memcache type of cache. List of memcache servers.
23+
memcachedServers:
24+
- "127.0.0.1:1234"
25+
- "127.0.0.2:1235"
26+
# Amount of CPUs to use. 0 - unlimited
27+
cpus: 0
28+
# Timezone, default - local
29+
tz: ""
30+
# If 'true', carbonapi will send requests as is, with globs and braces
31+
# Otherwise for each request it will generate /metrics/find and then /render
32+
# individual metrics.
33+
# true --- faster, but will cause carbonzipper to consume much more RAM.
34+
#
35+
# For some backends (e.x. graphite-clickhouse) this *MUST* be set to true in order
36+
# to get reasonable performance
37+
#
38+
# For go-carbon --- it depends on how you use it.
39+
sendGlobsAsIs: false
40+
# If sendGlobsAsIs is set and resulting response will be larger than maxBatchSize
41+
# carbonapi will revert to old behavir. This allows you to use benifits of passing
42+
# globs as is but keep memory usage in sane limits.
43+
#
44+
# For go-carbon you might want it to keep in some reasonable limits, 100 is good "safe" defaults
45+
#
46+
# For some backends (e.x. graphite-clickhouse) you might want to set it to some insanly high value, like 100000
47+
maxBatchSize: 100
48+
graphite:
49+
# Host:port where to send internal metrics
50+
# Empty = disabled
51+
host: "localhost:2003"
52+
interval: "60s"
53+
prefix: "carbon.api"
54+
# Maximium idle connections to carbonzipper
55+
idleConnections: 10
56+
pidFile: ""
57+
# See https://github.com/go-graphite/carbonzipper/blob/master/example.conf#L70-L108 for format explanation
58+
logger:
59+
- logger: ""
60+
file: "stderr"
61+
level: "debug"
62+
encoding: "console"
63+
encodingTime: "iso8601"
64+
encodingDuration: "seconds"
65+
- logger: ""
66+
file: "carbonapi.log"
67+
level: "info"
68+
encoding: "json"

conf/etc/go-carbon/go-carbon.conf

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
[common]
2+
# Run as user. Works only in daemon mode
3+
user = "carbon"
4+
# Prefix for store all internal go-carbon graphs. Supported macroses: {host}
5+
graph-prefix = "carbon.agents.{host}"
6+
# Endpoint for store internal carbon metrics. Valid values: "" or "local", "tcp://host:port", "udp://host:port"
7+
metric-endpoint = "local"
8+
# Interval of storing internal metrics. Like CARBON_METRIC_INTERVAL
9+
metric-interval = "1m0s"
10+
# Increase for configuration with multi persister workers
11+
max-cpu = 4
12+
13+
[whisper]
14+
data-dir = "/var/lib/graphite/whisper"
15+
# http://graphite.readthedocs.org/en/latest/config-carbon.html#storage-schemas-conf. Required
16+
schemas-file = "/etc/go-carbon/storage-schemas.conf"
17+
# http://graphite.readthedocs.org/en/latest/config-carbon.html#storage-aggregation-conf. Optional
18+
aggregation-file = "/etc/go-carbon/storage-aggregation.conf"
19+
# Worker threads count. Metrics sharded by "crc32(metricName) % workers"
20+
workers = 8
21+
# Limits the number of whisper update_many() calls per second. 0 - no limit
22+
max-updates-per-second = 0
23+
# Sparse file creation
24+
sparse-create = true
25+
enabled = true
26+
27+
[cache]
28+
# Limit of in-memory stored points (not metrics)
29+
max-size = 1000000
30+
# Capacity of queue between receivers and cache
31+
# Strategy to persist metrics. Values: "max","sorted","noop"
32+
# "max" - write metrics with most unwritten datapoints first
33+
# "sorted" - sort by timestamp of first unwritten datapoint.
34+
# "noop" - pick metrics to write in unspecified order,
35+
# requires least CPU and improves cache responsiveness
36+
write-strategy = "max"
37+
38+
[udp]
39+
listen = ":2003"
40+
enabled = true
41+
# Enable optional logging of incomplete messages (chunked by max UDP packet size)
42+
log-incomplete = false
43+
# Optional internal queue between receiver and cache
44+
buffer-size = 0
45+
46+
[tcp]
47+
listen = ":2003"
48+
enabled = true
49+
# Optional internal queue between receiver and cache
50+
buffer-size = 0
51+
52+
[pickle]
53+
listen = ":2004"
54+
# Limit message size for prevent memory overflow
55+
max-message-size = 67108864
56+
enabled = true
57+
# Optional internal queue between receiver and cache
58+
buffer-size = 0
59+
60+
[carbonlink]
61+
listen = "127.0.0.1:7002"
62+
enabled = false
63+
# Close inactive connections after "read-timeout"
64+
read-timeout = "30s"
65+
66+
[carbonserver]
67+
# Please NOTE: carbonserver is not intended to fully replace graphite-web
68+
# It acts as a "REMOTE_STORAGE" for graphite-web or carbonzipper/carbonapi
69+
listen = "127.0.0.1:8080"
70+
# Carbonserver support is still experimental and may contain bugs
71+
# Or be incompatible with github.com/grobian/carbonserver
72+
enabled = true
73+
# Buckets to track response times
74+
buckets = 10
75+
# carbonserver-specific metrics will be sent as counters
76+
# For compatibility with grobian/carbonserver
77+
metrics-as-counters = false
78+
# Read and Write timeouts for HTTP server
79+
read-timeout = "60s"
80+
write-timeout = "60s"
81+
# Enable /render cache, it will cache the result for 1 minute
82+
query-cache-enabled = true
83+
# 0 for unlimited
84+
query-cache-size-mb = 0
85+
# Enable /metrics/find cache, it will cache the result for 5 minutes
86+
find-cache-enabled = true
87+
# Control trigram index
88+
# This index is used to speed-up /find requests
89+
# However, it will lead to increased memory consumption
90+
# Estimated memory consumption is approx. 500 bytes per each metric on disk
91+
# Another drawback is that it will recreate index every scan-frequency interval
92+
# All new/deleted metrics will still be searchable until index is recreated
93+
trigram-index = true
94+
# carbonserver keeps track of all available whisper files
95+
# in memory. This determines how often it will check FS
96+
# for new or deleted metrics.
97+
scan-frequency = "5m0s"
98+
# Maximum amount of globs in a single metric in index
99+
# This value is used to speed-up /find requests with
100+
# a lot of globs, but will lead to increased memory consumption
101+
max-globs = 100
102+
# graphite-web-10-mode
103+
# Use Graphite-web 1.0 native structs for pickle response
104+
# This mode will break compatibility with graphite-web 0.9.x
105+
# If false, carbonserver won't send graphite-web 1.0 specific structs
106+
# That might degrade performance of the cluster
107+
# But will be compatible with both graphite-web 1.0 and 0.9.x
108+
graphite-web-10-strict-mode = true
109+
110+
[dump]
111+
# Enable dump/restore function on USR2 signal
112+
enabled = true
113+
# Directory for store dump data. Should be writeable for carbon
114+
path = "/var/lib/graphite/dump/"
115+
# Restore speed. 0 - unlimited
116+
restore-per-second = 0
117+
118+
[pprof]
119+
listen = "localhost:7007"
120+
enabled = false
121+
122+
# Default logger
123+
[[logging]]
124+
# logger name
125+
# available loggers:
126+
# * "" - default logger for all messages without configured special logger
127+
# @TODO
128+
logger = ""
129+
# Log output: filename, "stderr", "stdout", "none", "" (same as "stderr")
130+
file = "stdout"
131+
# Log level: "debug", "info", "warn", "error", "dpanic", "panic", and "fatal"
132+
level = "info"
133+
# Log format: "json", "console", "mixed"
134+
encoding = "mixed"
135+
# Log time format: "millis", "nanos", "epoch", "iso8601"
136+
encoding-time = "iso8601"
137+
# Log duration format: "seconds", "nanos", "string"
138+
encoding-duration = "seconds"
139+
140+
# You can define multiply loggers:
141+
142+
# Copy errors to stderr for systemd
143+
# [[logging]]
144+
# logger = ""
145+
# file = "stderr"
146+
# level = "error"
147+
# encoding = "mixed"
148+
# encoding-time = "iso8601"
149+
# encoding-duration = "seconds"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Documentation:
2+
# http://graphite.readthedocs.io/en/latest/config-carbon.html#storage-aggregation-conf
3+
4+
[default]
5+
pattern = .*
6+
xFilesFactor = 0.5
7+
aggregationMethod = average
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Documentation:
2+
# http://graphite.readthedocs.io/en/latest/config-carbon.html#storage-schemas-conf
3+
4+
[default]
5+
pattern = .*
6+
retentions = 60s:30d,1h:5y
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/var/log/*.log /var/log/*/*.log {
2+
weekly
3+
size 50M
4+
missingok
5+
rotate 10
6+
compress
7+
delaycompress
8+
notifempty
9+
copytruncate
10+
su root syslog
11+
}

0 commit comments

Comments
 (0)