Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
go-carbon with built-in carbonserver enabled, carbonapi and grafana setup memo
# setup go
curl -sS https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz | tar zxf - -C /usr/local
export PATH=/usr/local/go/bin:$HOME/go/bin:$PATH
yum install -y make git
# setup go-carbon
go get -d github.com/lomik/go-carbon
cd $HOME/go/src/github.com/lomik/go-carbon
#git checkout v0.9.1
git checkout e0fae152afccbc0133fb7babe48c4f708456f639
make submodules
make
install go-carbon /usr/local/sbin/
/usr/local/sbin/go-carbon --config-print-default | sed '/^\[carbonserver\]/,/^enabled/s/enabled = false/enabled = true/' > /etc/go-carbon.conf
mkdir -p /var/log/go-carbon /data/graphite/whisper
cat > /data/graphite/schemas <<'EOF'
[carbon]
pattern = ^carbon\.
retentions = 60s:14d
[example]
pattern = ^local\.random\.diceroll
retentions = 60s:14d
[grafana]
pattern = ^prod\.grafana\.
retentions = 60s:14d
EOF
useradd -r carbon
chown -R carbon: /var/log/go-carbon /data/graphite
cat > /etc/systemd/system/go-carbon.service <<'EOF'
[Unit]
Description=go-carbon server
Documentation=https://github.com/lomik/go-carbon
Wants=network-online.target
After=network-online.target
[Service]
User=carbon
Group=carbon
Type=simple
Restart=on-failure
ExecStart=/usr/local/sbin/go-carbon -config /etc/go-carbon.conf
LimitNOFILE=65536
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start go-carbon
systemctl enable go-carbon
# NOTE: You don't need carbonzipper if you run just one go-carbon and
# built-in carbonserver.
#
# # carbonzipper
# go get github.com/dgryski/carbonzipper/...
# install $HOME/go/bin/carbonzipper /usr/local/sbin/
# mkdir -p /var/log/carbonzipper
# chown -R carbon: /var/log/carbonzipper
#
# cat > /etc/carbonzipper.conf <<'EOF'
# {
# "Port": 8081,
# "MaxProcs": 0,
# "GraphiteHost": "127.0.0.1:2003",
# "IntervalSec": 60,
# "InternalMetricPrefix": "carbon.zipper",
# "Buckets": 10,
# "TimeoutMs": 10000,
# "TimeoutMsAfterAllStarted": 2000,
# "ConcurrencyLimitPerServer": 0,
# "MaxIdleConnsPerHost": 100,
# "Backends":
# [
# "http://127.0.0.1:8080"
# ],
# "SearchBackend": "",
# "SearchPrefix": "virt.v1.*",
# "Logger": [{
# "Logger": "",
# "File": "stderr",
# "Level": "debug",
# "Encoding": "console",
# "EncodingTime": "iso8601",
# "EncodingDuration": "seconds"
# },
# {
# "Logger": "",
# "File": "/var/log/carbonzipper/carbonzipper.log",
# "Level": "info",
# "Encoding": "json"
# }]
# }
# EOF
#
# cat > /etc/systemd/system/carbonzipper.service <<'EOF'
# [Unit]
# Description=carbonzipper server
# Documentation=https://github.com/dgryski/carbonzipper
# Wants=network-online.target go-carbon.service
# After=network-online.target go-carbon.service
#
# [Service]
# User=carbon
# Group=carbon
# Type=simple
# Restart=on-failure
# ExecStart=/usr/local/sbin/carbonzipper -c /etc/carbonzipper.conf
# LimitNOFILE=65536
# TimeoutStopSec=20
#
# [Install]
# WantedBy=multi-user.target
# EOF
# systemctl daemon-reload
# systemctl start carbonzipper
# systemctl enable carbonzipper
# setup carbonapi
go get -d github.com/dgryski/carbonapi/...
cd $HOME/go/src/github.com/dgryski/carbonapi
git checkout 476123ed195cb189048d0760d1c08a2e92502575
go get -d ./...
go install
install $HOME/go/bin/carbonapi /usr/local/sbin/
mkdir -p /var/log/carbonapi
chown carbon: /var/log/carbonapi
# NOTE: You may set URL of carbonserver to the zipper config below.
cat > /etc/carbonapi.yaml <<'EOF'
# Need to be URL, http or https
zipper: "http://localhost:8080"
# Listen address, should always include hostname or ip address and a port.
listen: "localhost:8082"
# Max concurrent requests to CarbonZipper
concurency: 20
cache:
type: "null"
# Amount of CPUs to use. 0 - unlimited
cpus: 0
# Timezone, default - local
tz: ""
# If 'true', carbonapi will send requests as is, with globs and braces
# Otherwise for each request it will generate /metrics/find and then /render
# individual metrics.
# true - faster, but will cause carbonzipper to consume much more RAM.
sendGlobsAsIs: false
graphite:
# Host:port where to send internal metrics
# Empty = disabled
host: ""
interval: "60s"
prefix: "carbon.api"
# Maximium idle connections to carbonzipper
idleConnections: 10
pidFile: ""
# See https://github.com/dgryski/carbonzipper/blob/master/example.conf#L70-L108 for format explanation
logger:
- logger: ""
file: "stderr"
level: "debug"
encoding: "console"
encodingTime: "iso8601"
encodingDuration: "seconds"
- logger: ""
file: "/var/log/carbonapi/carbonapi.log"
level: "info"
encoding: "json"
EOF
cat > /etc/systemd/system/carbonapi.service <<'EOF'
[Unit]
Description=carbonapi server
Documentation=https://github.com/dgryski/carbonapi
#Wants=network-online.target carbonzipper.service
#After=network-online.target carbonzipper.service
Wants=network-online.target go-carbon.service
After=network-online.target go-carbon.service
[Service]
User=carbon
Group=carbon
Type=simple
Restart=on-failure
ExecStart=/usr/local/sbin/carbonapi -config /etc/carbonapi.yaml
LimitNOFILE=65536
TimeoutStopSec=20
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start carbonapi
systemctl enable carbonapi
# setup grafana
yum install -y https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.2.0-1.x86_64.rpm
systemctl daemon-reload
sed -i.orig '/^\[metrics\.graphite\]/,/^$/s/;address =/address = localhost:2003/;s/^;prefix =/prefix =/' /etc/grafana/grafana.ini
systemctl start grafana-server
systemctl enable grafana-server
# http://docs.grafana.org/installation/rpm/#server-side-image-rendering
yum -y install fontconfig freetype* urw-fonts
@hnakamur

This comment has been minimized.

Copy link
Owner Author

commented Mar 30, 2017

grafana - graphite carbon metrics - google chrome 2017-03-31 03 43 25

@sacasumo

This comment has been minimized.

Copy link

commented Jul 26, 2017

great reference, learnt a nice few things!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.