Problem
Graphite doesn’t support special characters like “ “ (empty space), “/” slash etc. Because it expect everything to be just ASCII to split/processing them, and then make directories based on metric name.
For example:
Metric: datacenter1.server1.app1.metric1.abc
Will create datacenter1/server1/app1/metric1/abc.wsp
But Metric: datacentter1.this is a test/with/path.app.test will fail when create directory
So any special name not allow to appear in directory/file name is not supported by Graphite.
What we can do?
We can urlEncode the metric name which has special characters. So like “/var/opt” (not valid file name) will become “%2Fvar%2Fopt”(now valid), using urlEncode instead of others (like BASE64) is because this will keep most of data readable.
So what to change?
1. urlEncode metric name before send to Graphite (if you always sending metrics using text/line mode instead of pickle/batch mode, then you may consider modify Carbon-cache.py), like
metricname=quote(metricname, “*?[{”)
2. Change display code in Graphite web to correctly display metric name
a. On left side, in navigation panel
b. On graph legend
Code change.
1. In GRAPHITE_HOME/ webapp/graphite/metrics, edit file views.py < ---- this one is responsible for navigation tree
a. Find below lines in function tree_json
'text' : str(node.name)
Change to
'text' : unquote(str(node.name))b. Add below line at the beginning of the file if not exists already
from urllib import unquote2. In GRAPHITE_HOME/webapp/graphite/render, edit file glyph.py < ------ this one is used to draw graph
a. Find below line in function drawGraph (def drawGraph(self,**params):)
elements = [ (series.name,series.color,series.options.get('secondYAxis')) .....
change to
elements = [ (unquote(series.name),series.color,series.options.get('secondYAxis')) ….b. Add below line at the beginning of the file if not exists already
from urllib import unquote3. You’re done
Screenshot to give you a little big confidence:
here's what will happen when node repair is request (nodetool repair) definition: neighbors, the node(s) has replica of the data other node(s) has. For example, you have a 7 node cluster, and token is evenly distributed (that is, each node holds 1/7 range). Assume you set replication factor to 3. That means any data you write should have 3 replicas, under default strategy (SimpleStrategy) , the next two replicas will be put on the next node along the ring. So if the data you write is on node 4, then node 5 and 6 each will also have one replica. And node 4 should also hold one replica for node 3 and one replica for node 2. Then the neighbors for node 4 will be node 2,3,4,5 and 6. Using same logic, node 6’s neighbors will be 4,5,6,7 and 1 (remember it’s a ring, when you reaches end, the next will be the first node) you can do the same calculation for other node or for other replication factor. Steps: for each keyspace in Cassandra DB do below: ...
Intresting. Too bad it requires a code change to Graphite. Have you tried sending a pull request to Graphite about this?
ReplyDeletetried, they don't like my idea :(
Delete