Skip to content

Instantly share code, notes, and snippets.

@ifrost
Last active November 23, 2021 13:54
Show Gist options
  • Save ifrost/e8faa2976caf610e9e03ec815ce83d82 to your computer and use it in GitHub Desktop.
Save ifrost/e8faa2976caf610e9e03ec815ce83d82 to your computer and use it in GitHub Desktop.
Graphite: Manual testing scenarios
Prerequisites:
- use `make devenv sources=graphite`
- each tests starts with plain Explore or Dashboard state
- select "gdev-graphite" datasouce
Metrics: adding and editing
- click on "select metric"
- select "stats" -> "stats" should be selected and a new segment with "select metric" label should appear
- select "response" from the second segment
- select "500" from the last dropdown
- no more metric can be selected (there should be no "select metric" dropdown) and graph should appear immediately after selecting the last metric.
- change last dropdown from "500" to "*"
- metric should be updated and a new graph rendered with multiple lines
- click on Functions "+" button and add function "aliasByNode"
- aliasByNode(2) should be added. "2" param is added automatically. Legend label should be equal to status code (e.g. 500, 200)
- change "stats" to "carbon"
- existing segments should disappear, only "carbon" and "select metric" should be displayed, the graph disappears
Metrics time range:
- Open a metric (not tag) segment option
- Check network tab, look for /metrics/find endpoint
- Check if from/to match the currently selected time range
- Change the selected time range
- Check if from/to is updated when a segment is opened
Long metric names:
- Use raw editor to enter the query below:
alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar.foo.bar, 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test')
- switch to the visual editor (metric segments and functions should be wrapped)
- now enter a long query with tags:
alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(alias(seriesByTag(alias('name'), 'dc=eu-west-1', 'dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1','dc=eu-west-1', 'dc=eu-west-1', 'dc=eu-west-1', 'dc=eu-west-1', 'dc=eu-west-1', 'dc=eu-west-1', 'dc=eu-west-1'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test'), 'test test test test')
- switch to the visual editor (tag segments and functions should be wrapped)
Tags:
- open the first segment and select "tag: dc"
- editor should show "dc =" with an empty segment for the value and "play button" at the end
- click on the empty segment after "=" and choose "asia" as the value (graph should not be displayed yet)
- add another tag with "+" button and make it: "name = servers.requests.count" (graph should not be displayed yet)
- click play button - graph should be displayed
- change "dc = asia" to "dc = eu"
- graph should be updated
- change operator to "dc =~"
- change tag value to "dc =~ .*u.*"
- graph should be updated showing data for us and eu regions
- edit "dc" tag name with the keyboard to a random value
- click away -> the name should be updated to whatever was typed
- click on the first tag (with name you entered) and select "-- remove tag --" from the dropdown
- one tag should be visible "name = servers.requests.count" and graph should show data for all regions
Adding functions
- open raw editor and type: seriesByTag('dc=~.*u.*', 'name=servers.requests.count')
- switch to visual editor and verify tags were added correctly, no function should be added (seriesByTag is a hidden function used when tags are in use)
- add a function "aliasByTags"
- put params in the function "aliasByTag(dc,server)"
(note: it's possible to add both params by simply typing "dc,server" with comma as the first param. the editor will split it into two params
- graph should be displayed with correct legend (e.g. eu.server_001)
- add function "aggregate"
- a dropdown for the first param should appear, select "avg"
- aggregated graph should be displayed
- click on the "aggregate" function name
- hover over question mark - description should be displayed
- click on left arrow - functions should be swapped
- change last function param to "aliasByTags(aggregatedBy)"
- graph legend should be updated to "avg"
- change param of aggregate function to "sum"
- legend should be updated
- add one more param to aggregate(), e.g. server -> now remove that value by opening the dropdown and clicking away (second param should disappear); not try the same with the first param -> it should stay unchanged as this param is required
- click on "aggregate" function name and click "x"
- aggregate function should be removed and only aliasByTags should be visible
- remove all tags (one by one) -> it should be possible to add metrics/segments again
Functions with no segments
- switch to raw text editor
- type: "constantLine(10)"
- switch back to the editor - no segments should be displayed and no metrics allowed to be added
Interpolation by refId
- create first query in text editor: stats.response.*
- create second query in text editor: sum(#A)
- hide first query
- single line with sum of all lines should be displayed
*** DASHBOARDS ONLY ***
Scenarios below work only in dashboards.
Query refs in segment options
- create a new panel
- add any Graphite query
- change refId of the query to "foo"
- add another query using "Add query button"
- open "select metric"
- there should be an option in the list referecing the first query "#foo"
- NOTE: interplation with refIds other than a single capital letter (A-Z) has not worked since the beginning, but it should be fixed
Variables interpolation (only in dashboards)
- create a new panel
- create a variable:
- Name: dc
- Type: Query
- Data source: gdev-graphite
- Query: tag_values(dc)
- add a panel
- select "gdev-graphite"
- select tag "tag: dc"
- select value "${dc:regex}" from autocomplete
- click play button
- graph should be displayed
Alerts with sub-queries
- create a new panel
- add first query: "stats.response.*"
- add second query: "sum(#A)"
- save the dashboard
- create an alert with condition: "WHEN avg() query(A, 5m, now) IS ABOVE 0"
- click on "Test rule" at the bottom
- multiple results for each metric should be shown, e.g. "Metric: stats.response.200, Value: 0.18", Metric: stats.response.500, Value: 1.8"
- change condition to use the second query - query(B, 5m now)
- click on "Test rule" at the bottom
- single result should be returned, e.g. "Condition[0]: Eval: true, Metric: sumSeries(stats.response.*), Value: 0.207"
- there should be no message saying: "Condition: Eval: false, Query Returned No Series (reduced to null/no value)""
Duplicate:
- Creata a query "stats.response.200"
- Duplicate a query
- Drag and drop the query to swap them
- Change the top query -> it should not affect the other query
- See: https://github.com/grafana/grafana/issues/41557
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment