-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add some charts using k6 data (#656)
- Loading branch information
Showing
7 changed files
with
236 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { SceneFlexItem, SceneFlexLayout, SceneQueryRunner } from '@grafana/scenes'; | ||
import { DataSourceRef } from '@grafana/schema'; | ||
|
||
import { ExplorablePanel } from 'scenes/ExplorablePanel'; | ||
|
||
function getSentQueryRunner(metrics: DataSourceRef) { | ||
return new SceneQueryRunner({ | ||
datasource: metrics, | ||
queries: [ | ||
{ | ||
expr: `probe_data_sent_bytes{job="$job", instance="$instance"}`, | ||
instant: false, | ||
legendFormat: '{{ probe }}', | ||
range: true, | ||
refId: 'B', | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
function getReceivedQueryRunner(metrics: DataSourceRef) { | ||
return new SceneQueryRunner({ | ||
datasource: metrics, | ||
queries: [ | ||
{ | ||
expr: `probe_data_received_bytes{job="$job", instance="$instance"}`, | ||
instant: false, | ||
legendFormat: '{{ probe }}', | ||
range: true, | ||
refId: 'A', | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
export function getDataTransferred(metrics: DataSourceRef) { | ||
return new SceneFlexLayout({ | ||
height: 200, | ||
children: [ | ||
new SceneFlexItem({ | ||
width: '50%', | ||
body: new ExplorablePanel({ | ||
$data: getSentQueryRunner(metrics), | ||
pluginId: 'timeseries', | ||
title: 'Data sent', | ||
fieldConfig: { | ||
defaults: { | ||
unit: 'decbytes', | ||
}, | ||
overrides: [], | ||
}, | ||
}), | ||
}), | ||
new SceneFlexItem({ | ||
width: '50%', | ||
body: new ExplorablePanel({ | ||
$data: getReceivedQueryRunner(metrics), | ||
pluginId: 'timeseries', | ||
title: 'Data received', | ||
fieldConfig: { | ||
defaults: { | ||
unit: 'decbytes', | ||
}, | ||
overrides: [], | ||
}, | ||
}), | ||
}), | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SceneFlexItem, SceneQueryRunner } from '@grafana/scenes'; | ||
import { DataSourceRef } from '@grafana/schema'; | ||
|
||
import { ExplorablePanel } from 'scenes/ExplorablePanel'; | ||
|
||
function getQueryRunner(metrics: DataSourceRef) { | ||
return new SceneQueryRunner({ | ||
datasource: metrics, | ||
queries: [ | ||
{ | ||
expr: ` | ||
sum by (name) (probe_http_got_expected_response{job="$job", instance="$instance"}) | ||
/ | ||
count by (name) (probe_http_got_expected_response{job="$job", instance="$instance"})`, | ||
format: 'table', | ||
instant: true, | ||
legendFormat: '{{ name }}', | ||
range: false, | ||
refId: 'B', | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
export function getExpectedResponse(metrics: DataSourceRef) { | ||
return new SceneFlexItem({ | ||
body: new ExplorablePanel({ | ||
$data: getQueryRunner(metrics), | ||
pluginId: 'table', | ||
title: 'Expected response by target', | ||
fieldConfig: { | ||
defaults: { | ||
unit: 'percentunit', | ||
}, | ||
overrides: [ | ||
{ | ||
matcher: { | ||
id: 'byName', | ||
options: 'Time', | ||
}, | ||
properties: [ | ||
{ | ||
id: 'custom.hidden', | ||
value: true, | ||
}, | ||
], | ||
}, | ||
{ | ||
matcher: { | ||
id: 'byName', | ||
options: 'Value', | ||
}, | ||
properties: [ | ||
{ | ||
id: 'displayName', | ||
value: 'Expected status received', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { SceneFlexItem, SceneQueryRunner } from '@grafana/scenes'; | ||
import { DataSourceRef } from '@grafana/schema'; | ||
|
||
import { ExplorablePanel } from 'scenes/ExplorablePanel'; | ||
|
||
function getQueryRunner(metrics: DataSourceRef) { | ||
return new SceneQueryRunner({ | ||
datasource: metrics, | ||
queries: [ | ||
{ | ||
refId: 'A', | ||
expr: ` | ||
sum by (name) (probe_http_requests_total{job="$job", instance="$instance"}) | ||
/ | ||
count by (name) (probe_http_requests_total{job="$job", instance="$instance"})`, | ||
range: true, | ||
instant: false, | ||
legendFormat: '{{ name }}', | ||
format: 'time_series', | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
export function getSuccessRateByUrl(metrics: DataSourceRef) { | ||
return new SceneFlexItem({ | ||
body: new ExplorablePanel({ | ||
$data: getQueryRunner(metrics), | ||
pluginId: 'timeseries', | ||
title: 'Success rate by target', | ||
fieldConfig: { | ||
defaults: { | ||
unit: 'percentunit', | ||
max: 1, | ||
}, | ||
overrides: [], | ||
}, | ||
}), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SceneFlexItem, SceneQueryRunner } from '@grafana/scenes'; | ||
import { DataSourceRef } from '@grafana/schema'; | ||
|
||
import { ExplorablePanel } from 'scenes/ExplorablePanel'; | ||
|
||
function getQueryRunner(metrics: DataSourceRef) { | ||
return new SceneQueryRunner({ | ||
datasource: metrics, | ||
queries: [ | ||
{ | ||
refId: 'A', | ||
expr: 'sum by(name)(rate(probe_http_duration_seconds{job="$job", instance="$instance"}[5m]))', | ||
range: true, | ||
legendFormat: '{{ name }}', | ||
format: 'time_series', | ||
}, | ||
], | ||
}); | ||
} | ||
export function getTimingByTarget(metrics: DataSourceRef) { | ||
return new SceneFlexItem({ | ||
body: new ExplorablePanel({ | ||
$data: getQueryRunner(metrics), | ||
pluginId: 'timeseries', | ||
title: 'Timing by target', | ||
fieldConfig: { | ||
defaults: { | ||
unit: 's', | ||
}, | ||
overrides: [], | ||
}, | ||
}), | ||
}); | ||
} |