Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite dashboard creator #2828

Merged
merged 9 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions blueprints/auto-scaling/pod-auto-scaler/bundle.libsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local creator = import '../../grafana/creator.libsonnet';
local utils = import '../../utils/utils.libsonnet';
local blueprint = import './pod-auto-scaler.libsonnet';

Expand Down Expand Up @@ -89,12 +88,6 @@ function(params) {
},

local p = policy(updated_cfg),
local d = creator(p.policyResource, updated_cfg),

dashboards: {
[std.format('%s.json', updated_cfg.policy.policy_name)]: d.dashboard,
} + d.receiverDashboards,

policies: {
[std.format('%s-cr.yaml', updated_cfg.policy.policy_name)]: p.policyResource,
[std.format('%s.yaml', updated_cfg.policy.policy_name)]: p.policyDef,
Expand Down
6 changes: 6 additions & 0 deletions blueprints/grafana/actuator_library.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
AdaptiveLoadScheduler: import './panels/grouped/load_scheduler.libsonnet',
AIMDLoadScheduler: import './panels/grouped/load_scheduler.libsonnet',
RangeDrivenLoadScheduler: import './panels/grouped/load_scheduler.libsonnet',
AIADLoadScheduler: import './panels/grouped/load_scheduler.libsonnet',
}
kwapik marked this conversation as resolved.
Show resolved Hide resolved
80 changes: 0 additions & 80 deletions blueprints/grafana/creator.libsonnet

This file was deleted.

28 changes: 9 additions & 19 deletions blueprints/grafana/dashboard_group.libsonnet
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
local creator = import 'creator.libsonnet';
local signals = import 'signals_dashboard.libsonnet';
local infraMetersDashboards = import 'infra_meter_dashboard.libsonnet';
local signalsDashboard = import 'signals_dashboard.libsonnet';
local summaryDashboard = import 'summary_dashboard.libsonnet';

function(policyJSON, cfg) {
local policyName = cfg.policy.policy_name,
local dashboards = creator(policyJSON, cfg),
local mainDashboard = dashboards.dashboard,
local receiverDashboards = dashboards.receiverDashboards,
function(policyFile, componentsList, policyName, datasource, extraFilters={}) {
local summary = summaryDashboard(componentsList, policyName, datasource, extraFilters).dashboard,
local receivers = infraMetersDashboards(policyFile, policyName, datasource, extraFilters).dashboards,

local signalsDashboard = signals({
policy+: {
policy_name: policyName,
},
dashboard+: {
title: 'Aperture Signals - %s' % policyName,
},
}).dashboard,

mainDashboard: mainDashboard,
signalsDashboard: signalsDashboard,
receiverDashboards: receiverDashboards,
dashboards: {
summary: summary,
} + receivers,
}
30 changes: 30 additions & 0 deletions blueprints/grafana/infra_meter_dashboard.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local base = import './utils/base_dashboard.libsonnet';
local defaultConfig = import './utils/default_config.libsonnet';
local unwrapInfraMeter = import './utils/unwrap_infra_meter_panel.libsonnet';

local g = import 'github.com/grafana/grafonnet/gen/grafonnet-v9.4.0/main.libsonnet';

function(policyFile, policyName, datasource, extraFilters={}) {
local receiverDashboard = base('Receiver Dashboard - %s' % policyName, defaultConfig.dashboard.refresh_interval),
local policyJSON = std.parseYaml(policyFile),

local infraMeters =
if std.objectHas(policyJSON, 'spec') &&
std.objectHas(policyJSON.spec, 'resources') &&
std.objectHas(policyJSON.spec.resources, 'infra_meters') &&
std.length(std.objectFields(policyJSON.spec.resources.infra_meters)) > 0
then policyJSON.spec.resources.infra_meters
else {},

local receiverDashboards = {
['receiver' + '-' + infraMeter + '-' + receiver]:
receiverDashboard.baseDashboard + g.dashboard.withPanels(
unwrapInfraMeter(receiver, policyName, infraMeter, datasource, extraFilters).panel
)
for infraMeter in std.objectFields(infraMeters)
if std.objectHas(infraMeters[infraMeter], 'receivers')
for receiver in std.objectFields(infraMeters[infraMeter].receivers)
},

dashboards: receiverDashboards,
}
1 change: 0 additions & 1 deletion blueprints/grafana/infra_meter_panel_library.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
postgresql: import './panels/grouped/pgsql.libsonnet',
elasticsearch: import './panels/grouped/elasticsearch.libsonnet',
rabbitmq: import './panels/grouped/rabbitmq.libsonnet',

}
32 changes: 5 additions & 27 deletions blueprints/grafana/panel_library.libsonnet
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
{
accept_percentage: import './panels/accept_percentage.libsonnet',
accepted_token_rate: import './panels/accepted_token_rate.libsonnet',
average_load_multiplier: import './panels/average_load_multiplier.libsonnet',
incoming_token_rate: import './panels/incoming_token_rate.libsonnet',
rate_limiter: import './panels/rate_limiter.libsonnet',
signal_average: import './panels/signal_average.libsonnet',
signal_frequency: import './panels/signal_frequency.libsonnet',
throughput: import './panels/throughput.libsonnet',
token_bucket_available_tokens: import './panels/token_bucket_available_tokens.libsonnet',
token_bucket_capacity: import './panels/token_bucket_capacity.libsonnet',
token_bucket_fillrate: import './panels/token_bucket_fillrate.libsonnet',
wfq_scheduler_flows: import './panels/wfq_scheduler_flows.libsonnet',
wfq_scheduler_heap_requests: import './panels/wfq_scheduler_heap_requests.libsonnet',
workload_decisions_accepted: import './panels/workload_decisions_accepted.libsonnet',
workload_decision_rejected: import './panels/workload_decisions_rejected.libsonnet',
workload_latency: import './panels/workload_latency.libsonnet',
query: import './panels/query.libsonnet',
quota_checks: import './panels/quota_checks.libsonnet',
RateLimiter: import './panels/rate_limiter.libsonnet',
PromQL: import './panels/query.libsonnet',

// Grouped panels
adaptive_load_scheduler: import './panels/grouped/load_scheduler.libsonnet',
aimd_load_scheduler: import './panels/grouped/load_scheduler.libsonnet',
range_driven_load_scheduler: import './panels/grouped/load_scheduler.libsonnet',
aiad_load_scheduler: import './panels/grouped/load_scheduler.libsonnet',
auto_scale: import './panels/grouped/auto_scale.libsonnet',
signals: import './panels/grouped/signals.libsonnet',
load_ramp: import './panels/grouped/load_ramp.libsonnet',
quota_scheduler: import './panels/grouped/quota_scheduler.libsonnet',

AutoScale: import './panels/grouped/auto_scale.libsonnet',
Sampler: import './panels/grouped/load_ramp.libsonnet',
QuotaScheduler: import './panels/grouped/quota_scheduler.libsonnet',
}
7 changes: 4 additions & 3 deletions blueprints/grafana/panels/accept_percentage.libsonnet
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
local utils = import '../utils/policy_utils.libsonnet';
local timeSeriesPanel = import '../utils/time_series_panel.libsonnet';

function(cfg) {
local stringFilters = utils.dictToPrometheusFilter(cfg.dashboard.extra_filters { policy_name: cfg.policy.policy_name }),
function(datasourceName, policyName, component, extraFilters={}) {
local componentID = std.get(component.component, 'load_scheduler_component_id', default=component.component_id),
local stringFilters = utils.dictToPrometheusFilter(extraFilters { policy_name: policyName, component_id: componentID }),
kwapik marked this conversation as resolved.
Show resolved Hide resolved
local acceptPercentage_filters = utils.dictToPrometheusFilter(stringFilters { signal_name: 'ACCEPT_PERCENTAGE' }),

local acceptPercentage = timeSeriesPanel('Accept Percentage',
cfg.dashboard.datasource.name,
datasourceName,
'increase(signal_reading_sum{%(filters)s}[$__rate_interval]) / increase(signal_reading_count{%(filters)s}[$__rate_interval])',
acceptPercentage_filters),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ local timeSeriesPanel = import '../utils/time_series_panel.libsonnet';

local g = import 'github.com/grafana/grafonnet/gen/grafonnet-v9.4.0/main.libsonnet';

function(cfg) {
local stringFilters = utils.dictToPrometheusFilter(cfg.dashboard.extra_filters { policy_name: cfg.policy.policy_name }),
function(datasourceName, policyName, component, extraFilters={}) {
local stringFilters = utils.dictToPrometheusFilter(extraFilters { policy_name: policyName }),

local acceptedVsRejectedTargets = [
g.query.prometheus.new(cfg.dashboard.datasource.name, 'sum(rate(accepted_tokens_total{%(filters)s}[$__rate_interval]))' % { filters: stringFilters })
g.query.prometheus.new(datasourceName, 'sum(rate(accepted_tokens_total{%(filters)s}[$__rate_interval]))' % { filters: stringFilters })
+ g.query.prometheus.withIntervalFactor(1)
+ g.query.prometheus.withLegendFormat('Accepted Token Rate'),

g.query.prometheus.new(cfg.dashboard.datasource.name, 'sum(rate(rejected_tokens_total{%(filters)s}[$__rate_interval]))' % { filters: stringFilters })
g.query.prometheus.new(datasourceName, 'sum(rate(rejected_tokens_total{%(filters)s}[$__rate_interval]))' % { filters: stringFilters })
+ g.query.prometheus.withIntervalFactor(1)
+ g.query.prometheus.withLegendFormat('Rejected Token Rate'),
],

local acceptedVsRejected = timeSeriesPanel('Accepted Token Rate vs Rejected Token Rate', cfg.dashboard.datasource.name, 'Token Rate', stringFilters, targets=acceptedVsRejectedTargets, h=8, w=12),
local acceptedVsRejected = timeSeriesPanel('Accepted Token Rate vs Rejected Token Rate', datasourceName, 'Token Rate', stringFilters, targets=acceptedVsRejectedTargets, h=8, w=12),

panel: acceptedVsRejected.panel,
}
7 changes: 4 additions & 3 deletions blueprints/grafana/panels/average_load_multiplier.libsonnet
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
local utils = import '../utils/policy_utils.libsonnet';
local statPanel = import '../utils/stat_panel.libsonnet';

function(cfg) {
local stringFilters = utils.dictToPrometheusFilter(cfg.dashboard.extra_filters { policy_name: cfg.policy.policy_name }),
function(datasourceName, policyName, component, extra_filters={}) {
local componentID = std.get(component.component, 'load_scheduler_component_id', default=component.component_id),
local stringFilters = utils.dictToPrometheusFilter(extra_filters { policy_name: policyName, component_id: componentID }),

local avgLoadMultiplier = statPanel('Average Load Multiplier',
cfg.dashboard.datasource.name,
datasourceName,
'avg(token_bucket_lm_ratio{%(filters)s})',
stringFilters),

Expand Down
6 changes: 3 additions & 3 deletions blueprints/grafana/panels/avg_preemption_chart.libsonnet
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local barChartPanel = import '../utils/bar_chart_panel.libsonnet';
local utils = import '../utils/policy_utils.libsonnet';

function(cfg) {
local stringFilters = utils.dictToPrometheusFilter(cfg.dashboard.extra_filters { policy_name: cfg.policy.policy_name }),
function(datasourceName, policyName, component, extraFilters={}) {
local stringFilters = utils.dictToPrometheusFilter(extraFilters { policy_name: policyName }),

local preemptionRequest = barChartPanel('Average Preemption Tokens per Request by Workload',
cfg.dashboard.datasource.name,
datasourceName,
'( sum by (workload_index) (rate(workload_preempted_tokens_sum{%(filters)s}[$__range])) - sum by (workload_index) (rate(workload_delayed_tokens_sum{%(filters)s}[$__range])) ) / (( sum by (workload_index) (rate(workload_preempted_tokens_count{%(filters)s}[$__range])) + sum by (workload_index) (rate(workload_delayed_tokens_count{%(filters)s}[$__range])) + sum by (workload_index) (rate(workload_on_time_total{%(filters)s}[$__range])) ) != 0)',
stringFilters,
description='Preemption measures the average number of tokens by which a request from a specific workload was preempted, compared to a purely FIFO (first-in-first-out) ordering of requests. A negative preemption value indicates that the workload was delayed rather than preempted.',
kwapik marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local utils = import '../utils/policy_utils.libsonnet';
local timeSeriesPanel = import '../utils/time_series_panel.libsonnet';

function(cfg) {
local stringFilters = utils.dictToPrometheusFilter(cfg.dashboard.extra_filters { policy_name: cfg.policy.policy_name }),
function(datasourceName, policyName, component, extraFilters={}) {
local stringFilters = utils.dictToPrometheusFilter(extraFilters { policy_name: policyName }),

local avgPreemption = timeSeriesPanel('Average preemption per request by Workload',
cfg.dashboard.datasource.name,
datasourceName,
'( sum by (workload_index) (rate(workload_preempted_tokens_sum{%(filters)s}[$__rate_interval])) - sum by (workload_index) (rate(workload_delayed_tokens_sum{%(filters)s}[$__rate_interval])) ) / (( sum by (workload_index) (rate(workload_preempted_tokens_count{%(filters)s}[$__rate_interval])) + sum by (workload_index) (rate(workload_delayed_tokens_count{%(filters)s}[$__rate_interval])) + sum by (workload_index) (rate(workload_on_time_total{%(filters)s}[$__rate_interval])) ) != 0)',
stringFilters,
axisLabel='Tokens',
Expand Down
Loading
Loading