Skip to content

Instantly share code, notes, and snippets.

@replay
Last active November 19, 2019 02:11
Show Gist options
  • Save replay/7a9b97557cb5cb4e5fc51ed46b12f296 to your computer and use it in GitHub Desktop.
Save replay/7a9b97557cb5cb4e5fc51ed46b12f296 to your computer and use it in GitHub Desktop.
* Spinning up MT cluster which consists of 4 shard groups, 2 MTs per shard.
Each read MT has 10G Mem and 2 CPU cores on GKE n1-highmem-2 nodes.
* Feeding it with a fakemetrics generator. In total it generates 5 million metrics,
each metric has 12 tags:
8 of them have the same tags and values for all metrics.
3 of them have a unique value for each metric
1 is a tag of the format "host=[0-9]+"
in total there are 30k possible values for this tag then they start to repeat,
so each possible value such as "host=123" has 5M/30k = 166 metrics associated.
* 30k Meta records get generated. Each of the records is associated with one "host=X"
tag/value, so there are 166 metrics per meta record.
* Each meta record has 3 meta tags:
1 is of the format "datacenter=dc[0-2]" and there are only 3 possible values. So each
key/value combination corresponds to 30k/3 = 10k metrics
1 has only a single tag/value "stage=prod"
1 has two possible values which are "operatingSystem=windows" and "operatingSystem=redhat",
66% of the meta records get redhat, 33% get windows
* Waiting until all Metrictank instances have loaded all the meta records
* Submitting queries and timing them:
### test 1: querying single metric to test if result has been enriched with meta tags correctly
time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=seriesByTag("region=west99003")&maxDataPoints=1' | jq
real 0m 0.02s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "some.id.of.a.metric.99003;afewmoretags=forgoodmeasure;anothertag=somelongervalue;datacenter=dc3;goodforpeoplewhojustusetags=forbasicallyeverything;host=9002;lotsandlotsoftags=morefunforeveryone;manymoreother=lotsoftagstointern;onetwothreefourfivesix=seveneightnineten;operatingSystem=redhat;os=ubuntu;region=west99003;secondkey=anothervalue99003;stage=prod;thirdkey=onemorevalue99003",
"tags": {
"stage": "prod",
"datacenter": "dc3",
"lotsandlotsoftags": "morefunforeveryone",
"operatingSystem": "redhat",
"afewmoretags": "forgoodmeasure",
"anothertag": "somelongervalue",
"thirdkey": "onemorevalue99003",
"goodforpeoplewhojustusetags": "forbasicallyeverything",
"name": "some.id.of.a.metric.99003",
"os": "ubuntu",
"region": "west99003",
"secondkey": "anothervalue99003",
"host": "9002",
"manymoreother": "lotsoftagstointern",
"onetwothreefourfivesix": "seveneightnineten"
},
"datapoints": [
[
88686.84348296668,
1574128200
]
]
}
]
### test 2: querying region (metric tag) by prefix and then filtering result set by dc (meta tag)
/ # time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=countSeries(seriesByTag("region^=west49999"))&maxDataPoints=1' | jq
real 0m 0.51s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "countSeries(seriesByTag(\"region^=west49999\"))",
"tags": {
"name": "countSeries(seriesByTag(\"region^=west49999\"))"
},
"datapoints": [
[
110,
1574128200
]
]
}
]
/ # time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=countSeries(seriesByTag("datacenter=dc2","region^=west49999"))&maxDataPoints=1' | jq
real 0m 0.70s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "countSeries(seriesByTag(\"datacenter=dc2\",\"region^=west49999\"))",
"tags": {
"name": "countSeries(seriesByTag(\"datacenter=dc2\",\"region^=west49999\"))"
},
"datapoints": [
[
36,
1574128300
]
]
}
]
### test 3: querying large result set via metric tag, then filtering result set by a meta tag that matches all metrics (heavy query)
/ # time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=countSeries(seriesByTag("secondkey^=anothervalue1234"))&maxDataPoints=1' | jq
real 0m 1.71s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "countSeries(seriesByTag(\"secondkey^=anothervalue1234\"))",
"tags": {
"name": "countSeries(seriesByTag(\"secondkey^=anothervalue1234\"))"
},
"datapoints": [
[
1096,
1574128400
]
]
}
]
/ # time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=countSeries(seriesByTag("secondkey^=anothervalue1234","stage=prod"))&maxDataPoints=1' | jq
real 0m 8.61s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "countSeries(seriesByTag(\"secondkey^=anothervalue1234\",\"stage=prod\"))",
"tags": {
"name": "countSeries(seriesByTag(\"secondkey^=anothervalue1234\",\"stage=prod\"))"
},
"datapoints": [
[
1096,
1574128400
]
]
}
]
### test 4: query which involves 2 metric tags and 2 meta tags
/ # time curl -s -H 'X-Org-Id: 1' 'http://localhost:6060/render?target=countSeries(seriesByTag("host^=1111","afewmoretags=~forgoodmeasure","datacenter=dc2","stage=prod"))&maxDataPoints=1' | jq
real 0m 5.95s
user 0m 0.00s
sys 0m 0.00s
[
{
"target": "countSeries(seriesByTag(\"host^=1111\",\"afewmoretags=~forgoodmeasure\",\"datacenter=dc2\",\"stage=prod\"))",
"tags": {
"name": "countSeries(seriesByTag(\"host^=1111\",\"afewmoretags=~forgoodmeasure\",\"datacenter=dc2\",\"stage=prod\"))"
},
"datapoints": [
[
819,
1574128900
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment