Time Serie - Graphite (Storage and Visualization)
About
Graphite 1) is a metrics server software.
It does two things:
- Store metrics (numeric time-series data)
- Render graphs of this data on demand
The inherent scheme of organization in graphite is tree-like and hence the searches do-not/ can-not yield results from a different subtree. This makes it not-so-suitable for cross-dimensional searches.
It has a fixed-size database, similar in design and purpose to RRD. It originated at Orbitz in 2006 and was open sourced in 2008.
Tools
Docker
docker run -d --name=graphite -p 80:80 -p 2003:2003 -p 2004:2004 -p 7002:7002 nickstenning/graphite
where:
- 80: the graphite web interface
- 2003: the carbon-cache line receiver (the standard graphite protocol)
- 2004: the carbon-cache pickle receiver
- 7002: the carbon-cache query port (used by the web interface)
Then:
- Login to the graphite-web (a Django application) to http://dockerhost:80 with the username admin and password admin
- Graphite HOME is: /var/lib/graphite
Graphite Message Format
Graphite understands messages with this format:
metric_path value timestamp\n
where:
- metric_path is the metric namespace that you want to populate.
- value is the value that you want to assign to the metric at this time.
- timestamp is the unix epoch time in second !
Data
- Adding a metric
echo ${METRIC_NAME} ${METRIC_NUMBER} ${TIMESTAMP} | nc ${CARBON_HOST} ${CARBON_PORT}
# Example
echo "foo.bar 1 `date +%s`" | nc localhost 2003
where:
- foo.bar is the qualified named metric. bar is the name and foo its namespace. Graphite uses a dot-delimited namespace structure for metrics, graphs, and even dashboards
- nc: nc localhost 2003 creates a TCP connection to the port 2003 on the localhost. The standard input (ie foo.bar 1 1482334814) is sent to the host, and anything that comes back across the connection is sent to the standard output.
This metric would be stored in a Whisper database (wsp) at <prefix>/storage/whisper/foo/bar.wsp (Graphite prefix default to /opt/graphite).
Rendering
Start
Carbon can be started with the carbon-cache.py script:
GRAPHITE_HOME/bin/carbon-cache.py start
This starts the main Carbon daemon in the background.
Log
Logs are located in GRAPHITE_HOME/storage/log/carbon-cache/ for any errors.