I’m currently collecting disk usage data on EBS volumes across our farm and would like to trim down the path
field to a portion of the string for my alert message. I haven’t been able to find anything in the docs for a way to do this, and am unsure its possible. As an example, given this data point:
> select * from disk where path =~ /rexray\/volumes/ limit 1
{
"results": [
{
"series": [
{
"name": "disk",
"columns": [
"time",
"device",
"free",
"fstype",
"host",
"inodes_free",
"inodes_total",
"inodes_used",
"path",
"total",
"used",
"used_percent"
],
"values": [
[
1510339730000000000,
"xvdf",
15842684928,
"ext4",
"ip-xx-xx-xx-xx",
1046884,
1048576,
1692,
"/var/lib/docker/plugins/27f131b49545cc98d7320ff5478b218564629f2e7a29728d7570f4204211a610/rootfs/var/lib/rexray/volumes/service.volume.name",
16776032256,
57577472,
0.3621164893479997
]
]
}
]
}
]
}
I would like to be able to parse out the path value here i.e. "/var/lib/docker/plugins/27f131b49545cc98d7320ff5478b218564629f2e7a29728d7570f4204211a610/rootfs/var/lib/rexray/volumes/volume.name"
and only keep the last part of the value. Is there a way to set a var based on a regex? I’d like to run a regex similar to /([^/]+$)/g
against path
which would set the value to volume.name