1. Instructions
The following describes how to feed data. For more information about how to use statsd to feed data, see my fourth article: statsd guide.
There are three ways to feed data:
There are three main methods for sending data to graphite: plaintext, pickle, and amqp.
Choosing the right transfer method for you is dependent on how you want to build your application or script to send data:
- For a singular script, or for test data, the plaintext protocol is the most straightforward method.
- For sending large amounts of data, you'll want to batch this data up and send it to carbon's pickle handler er.
- Finally, carbon can listen to a message bus, via amqp.
The plaintext Protocol
The plaintext protocol is the most straightforward protocol supported by carbon.
The data sent must be in the following format:<Metricpath> <metricvalue> <metrictimestamp>.
Carbon will then help translate this line of text into a metric that the Web interface and whisper understand.
On UNIX,NCProgram can be used to create a socket and send data to carbon (by default, 'plaintext' runs on port 2003 ):
PORT=2003SERVER=graphite.your.orgecho "local.random.diceroll 4 `date +%s`" | nc ${SERVER} ${PORT};
The pickle Protocol
The pickle protocol is a much more efficient take on the plaintext protocol, and supports sending batches of metrics to carbon in one go.
The general idea is that the pickled data forms a list of multi-level tuples:
[(path, (timestamp, value)), ...]
Once you 've formed a list of sufficient size (don't go too big !), Send the data over a socket to carbon's pickle handler Er (by default, port 2004). You'll need to pack your pickled data into a packet containing a simple header:
payload = pickle.dumps(listOfMetricTuples)header = struct.pack("!L", len(payload))message = header + payload
You wocould then sendMessageObject through a network socket.
Using amqp
Amqp is an application-layer protocol specification used for asynchronous message transmission. As a line-layer protocol, rather than an API (such as JMS), The amqp client can send and receive messages without considering the source of the message.
This should not be easy to use
Problem:
The unit of the 1 y axis does not match the sent one.
2. Usage
To sum up, if you observe it occasionally, simply open the entire graphite (server: 8080). If it is used for a long time, it is easier to use dashboard.
However, if wildcards cannot be used on my computer, you can use the url api to obtain wildcards. If the dashboard is used, all the wildcards can be pulled to a single graph.
Reference: http://www.jsxubar.info/graphite-dashboard.html
The way to access the VM is server: 8080.
Variable usage Description: The variable name is expanded in the tree structure, for example, carbon. Agents. alg-1-a.cpuUsage indicates that the cpuusage variable is in the path of carbon. Agents. alg-1-a.
1 dashboard
As the name suggests, it is displayed as a panel.
In this way, you can select a project, draw a graph, and save it as a webpage. You can directly open the webpage.
Server: 8080/dashboard open panel
- When selecting a data source, you can use the wildcard "*", which is quite convenient. For example, if you want to compare the idle content of multiple hosts, you can use *. meminfo. Free for filtering.
- Find the bottom-layer information of the data source, and click it. Bold indicates that the data source is selected. The following figure shows the data source.
Select data, generate a chart, and save it as a dashboard. For example, save the CPU image information as a CPU, close the browser window, and you can use server next time: 8080/dashboard/# view the CPU.
When I open the panel next time, I do not remember the Panel I previously created. In this case, you can select the panel list through "Finder ".
When I was doing this, I found that the wildcard did not work, and the reaction was very slow .??????????????????
2 CLI
Command Line operations
Refer to the above mentioned jsxubar blog or official website http://graphite.wikidot.com/cli-reference
3. url API
Use the URL to directly obtain the desired image.
For example, http: // 127.0.0.1: 8080/render? Target = *. Test & target = *. bigboy & from =-60 min
Refer to the above mentioned jsxubar blog or official website http://graphite.wikidot.com/url-api-reference
Small points
Set ystep
Default: calculated automatically
Manually set the value step between Y-axis labels and grid lines
Main reference:
Graphite document: https://graphite.readthedocs.org can basically find everything