I am trying to create a grafana dashboard for cassandra and I need assistance how to filter a variable from the metric output.
Grafana Query:
label_values(collectd_dse_histogram_p98{cluster_name=~"$cluster",dse=~"org.apache.cassandra.metrics.table.read_latency.*.*"},dse)
Regex tried: org.apache.cassandra.metrics.table.read_latency.(.*)
Output I am getting is in the format keyspace.table_name
. Need assistance how a Regex expression be formatted to extract only keyspace
from the output.
Getting Output as "keyspace"."table_name"
Need only "keyspace" as output variable.
To match
keyspace
inorg.apache.cassandra.metrics.table.read_latency.keyspace.table_name
proper regex isorg\.apache\.cassandra\.metrics\.table\.read_latency\.(\[^.\]*)\..*
:It matches predefined prefix (while escaping dots, as the have special meaning in regex), and then it captures everything till next dot into a group.
Please notice that regex here matches full string.
/org\.apache\.cassandra\.metrics\.table\.read_latency\.([^.]*)/
might also work work, but in this case notice that regex is surrounded by/
.Difference is due to Grafana treating regexes differently depending on if they are enclosed in
/.../
or not. Those without slashes are added with anchors^
and$
automatically.