Skip to content

Commit 2a668b3

Browse files
committed
Refactored signal files to align with the dashboards instead of grouping by category.
1 parent 7eb4193 commit 2a668b3

File tree

11 files changed

+1019
-317
lines changed

11 files changed

+1019
-317
lines changed

squid-mixin/config.libsonnet

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,32 @@
22
local this = self,
33

44
// Basic filtering
5-
filteringSelector: 'job=~"$job", instance=~"$instance"',
5+
filteringSelector: 'job="integrations/squid"',
66
groupLabels: ['job'],
7+
logLabels: ['job', 'instance'],
78
instanceLabels: ['instance'],
89

910
// Dashboard settings
10-
dashboardTags: ['squid'],
11+
uid: 'squid',
12+
dashboardNamePrefix: 'Squid',
13+
dashboardTags: [self.uid],
1114
dashboardPeriod: 'now-1h',
1215
dashboardTimezone: 'default',
1316
dashboardRefresh: '1m',
14-
uid: 'squid',
15-
dashboardNamePrefix: 'Squid',
16-
17+
metricsSource: 'prometheus',
18+
1719
// Logs configuration
1820
enableLokiLogs: true,
19-
logLabels: ['job', 'instance', 'filename'],
20-
extraLogLabels: [],
21+
extraLogLabels: ['level', 'severity'],
2122
logsVolumeGroupBy: 'level',
2223
showLogsVolume: true,
2324

24-
// Multi-cluster support
25-
enableMultiCluster: false,
26-
multiclusterSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
27-
2825
// Alert thresholds
2926
alertsCriticalHighPercentageRequestErrors: 5, // %
3027
alertsWarningLowCacheHitRatio: 85, // %
3128

32-
// Metrics source
33-
metricsSource: 'prometheus',
34-
3529
// Signal definitions
3630
signals: {
3731
client: (import './signals/client.libsonnet')(this),
38-
server: (import './signals/server.libsonnet')(this),
39-
serviceTime: (import './signals/service_time.libsonnet')(this),
4032
},
4133
}

squid-mixin/dashboards.libsonnet

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,78 @@
11
local g = import './g.libsonnet';
22
local commonlib = import 'common-lib/common/main.libsonnet';
3+
local logslib = import 'logs-lib/logs/main.libsonnet';
34

45
{
56
local root = self,
67
new(this):
78
local prefix = this.config.dashboardNamePrefix;
89
local links = this.grafana.links;
910
local tags = this.config.dashboardTags;
10-
local uid = this.config.uid;
11-
local vars = commonlib.variables.new(
12-
filteringSelector=this.config.filteringSelector,
13-
groupLabels=this.config.groupLabels,
14-
instanceLabels=this.config.instanceLabels,
15-
varMetric='squid_server_http_requests_total',
16-
customAllValue='.+',
17-
enableLokiLogs=this.config.enableLokiLogs,
18-
);
19-
local annotations = {};
11+
local uid = g.util.string.slugify(this.config.uid);
12+
local vars = this.grafana.variables;
13+
local annotations = this.grafana.annotations;
2014
local refresh = this.config.dashboardRefresh;
2115
local period = this.config.dashboardPeriod;
2216
local timezone = this.config.dashboardTimezone;
23-
17+
local extraLogLabels = this.config.extraLogLabels;
2418
{
2519
'squid-overview.json':
2620
g.dashboard.new(prefix + ' overview')
2721
+ g.dashboard.withDescription('')
2822
+ g.dashboard.withPanels(
2923
g.util.panel.resolveCollapsedFlagOnRows(
30-
g.util.grid.wrapPanels(
31-
[
24+
g.util.grid.wrapPanels([
3225
this.grafana.rows.clientRow,
3326
this.grafana.rows.serverRow,
34-
]
35-
+
36-
if this.config.enableLokiLogs then
37-
[this.grafana.rows.logsRow]
38-
else
39-
[]
40-
)
27+
])
4128
)
4229
)
4330
+ root.applyCommon(
4431
vars.multiInstance,
4532
uid + '-overview',
4633
tags,
47-
links,
34+
links {squidOverview+:: {} },
4835
annotations,
4936
timezone,
5037
refresh,
5138
period
5239
),
53-
},
40+
} + if this.config.enableLokiLogs then {
41+
'squid-logs.json':
42+
logslib.new(
43+
this.config.dashboardNamePrefix + ' logs',
44+
datasourceName=this.grafana.variables.datasources.loki.name,
45+
datasourceRegex=this.grafana.variables.datasources.loki.regex,
46+
filterSelector=this.config.filteringSelector,
47+
labels=this.config.groupLabels + this.config.extraLogLabels,
48+
formatParser=null,
49+
showLogsVolume=this.config.showLogsVolume,
50+
)
51+
{
52+
dashboards+:
53+
{
54+
logs+:
55+
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
56+
},
57+
panels+:
58+
{
59+
logs+:
60+
g.panel.logs.options.withEnableLogDetails(true)
61+
+ g.panel.logs.options.withShowTime(false)
62+
+ g.panel.logs.options.withWrapLogMessage(false),
63+
},
64+
variables+: {
65+
toArray+: [
66+
this.grafana.variables.datasources.prometheus { hide: 2 },
67+
],
68+
},
69+
}.dashboards.logs,
70+
} else {},
5471

5572
applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
5673
g.dashboard.withTags(tags)
5774
+ g.dashboard.withUid(uid)
58-
+ g.dashboard.withLinks([links[key].asDashboardLink() for key in std.objectFields(links)])
75+
+ g.dashboard.withLinks(std.objectValues(links))
5976
+ g.dashboard.withTimezone(timezone)
6077
+ g.dashboard.withRefresh(refresh)
6178
+ g.dashboard.time.withFrom(period)

0 commit comments

Comments
 (0)