Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 3 additions & 7 deletions squid-mixin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ Squid logs are enabled by default in the `config.libsonnet` and can be removed b

```
{
_config+:: {
enableLokiLogs: false,
},
enableLokiLogs: false,
}
```

Expand Down Expand Up @@ -64,10 +62,8 @@ Default thresholds can be configured in `config.libsonnet`

```js
{
_config+:: {
alertsCriticalHighPercentageRequestErrors: 5,
alertsWarningLowCacheHitRatio: 85,
},
alertsCriticalHighPercentageRequestErrors: 5,
alertsWarningLowCacheHitRatio: 85,
}
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
prometheusAlerts+:: {
groups+: [
new(this): {
groups: [
{
name: 'squid',
name: this.config.uid + '-alerts',
rules: [
{
alert: 'SquidHighPercentageOfHTTPServerRequestErrors',
alert: 'SquidHighHTTPServerRequestErrors',
expr: |||
rate(squid_server_http_errors_total[5m]) / clamp_min(rate(squid_server_http_requests_total[5m]),1) * 100 > %(alertsCriticalHighPercentageRequestErrors)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -17,14 +17,14 @@
summary: 'There are a high number of HTTP server errors.',
description: |||
The percentage of HTTP server request errors is {{ printf "%%.0f" $value }} over the last 5m on {{ $labels.instance }} which is above the threshold of %(alertsCriticalHighPercentageRequestErrors)s.
||| % $._config,
||| % this.config,
},
},
{
alert: 'SquidHighPercentageOfFTPServerRequestErrors',
alert: 'SquidHighFTPServerRequestErrors',
expr: |||
rate(squid_server_ftp_errors_total[5m]) / clamp_min(rate(squid_server_ftp_requests_total[5m]),1) * 100 > %(alertsCriticalHighPercentageRequestErrors)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -33,14 +33,14 @@
summary: 'There are a high number of FTP server request errors.',
description: |||
The percentage of FTP server request errors is {{ printf "%%.0f" $value }} over the last 5m on {{ $labels.instance }} which is above the threshold of %(alertsCriticalHighPercentageRequestErrors)s.
||| % $._config,
||| % this.config,
},
},
{
alert: 'SquidHighPercentageOfOtherServerRequestErrors',
alert: 'SquidHighOtherServerRequestErrors',
expr: |||
rate(squid_server_other_errors_total[5m]) / clamp_min(rate(squid_server_other_requests_total[5m]),1) * 100 > %(alertsCriticalHighPercentageRequestErrors)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -49,14 +49,14 @@
summary: 'There are a high number of other server request errors.',
description: |||
The percentage of other server request errors is {{ printf "%%.0f" $value }} over the last 5m on {{ $labels.instance }} which is above the threshold of %(alertsCriticalHighPercentageRequestErrors)s.
||| % $._config,
||| % this.config,
},
},
{
alert: 'SquidHighPercentageOfClientRequestErrors',
alert: 'SquidHighClientRequestErrors',
expr: |||
rate(squid_client_http_errors_total[5m]) / clamp_min(rate(squid_client_http_requests_total[5m]),1) * 100 > %(alertsCriticalHighPercentageRequestErrors)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -65,14 +65,14 @@
summary: 'There are a high number of HTTP client request errors.',
description: |||
The percentage of HTTP client request errors is {{ printf "%%.0f" $value }} over the last 5m on {{ $labels.instance }} which is above the threshold of %(alertsCriticalHighPercentageRequestErrors)s.
||| % $._config,
||| % this.config,
},
},
{
alert: 'SquidLowCacheHitRatio',
expr: |||
rate(squid_client_http_hits_total[10m]) / clamp_min(rate(squid_client_http_requests_total[10m]),1) * 100 < %(alertsWarningLowCacheHitRatio)s
||| % $._config,
||| % this.config,
'for': '10m',
labels: {
severity: 'warning',
Expand All @@ -81,7 +81,7 @@
summary: 'The cache hit ratio has fallen below the configured threshold (%).',
description: |||
The cache hit ratio is {{ printf "%%.0f" $value }} over the last 10m on {{ $labels.instance }} which is below the threshold of %(alertsWarningLowCacheHitRatio)s.
||| % $._config,
||| % this.config,
},
},
],
Expand Down
41 changes: 29 additions & 12 deletions squid-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
{
_config+:: {
dashboardTags: ['squid'],
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
local this = self,

// alerts thresholds
alertsCriticalHighPercentageRequestErrors: 5,
alertsWarningLowCacheHitRatio: 85,
enableLokiLogs: true,
enableMultiCluster: false,
multiclusterSelector: 'job=~"$job"',
squidSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
// Basic filtering
filteringSelector: 'job="integrations/squid"',
groupLabels: ['job', 'cluster'],
logLabels: ['job', 'cluster', 'instance'],
instanceLabels: ['instance'],

// Dashboard settings
uid: 'squid',
dashboardNamePrefix: 'Squid',
dashboardTags: [self.uid],
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
metricsSource: 'prometheus',

// Logs configuration
enableLokiLogs: true,
extraLogLabels: ['level', 'severity'],
logsVolumeGroupBy: 'level',
showLogsVolume: true,

// Alert thresholds
alertsCriticalHighPercentageRequestErrors: 5, // %
alertsWarningLowCacheHitRatio: 85, // %

// Signal definitions
signals: {
overview: (import './signals/overview.libsonnet')(this),
},
}
81 changes: 81 additions & 0 deletions squid-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';
local logslib = import 'logs-lib/logs/main.libsonnet';

{
local root = self,
new(this):
local prefix = this.config.dashboardNamePrefix;
local links = this.grafana.links;
local tags = this.config.dashboardTags;
local uid = g.util.string.slugify(this.config.uid);
local vars = this.grafana.variables;
local annotations = this.grafana.annotations;
local refresh = this.config.dashboardRefresh;
local period = this.config.dashboardPeriod;
local timezone = this.config.dashboardTimezone;
local extraLogLabels = this.config.extraLogLabels;
{
'squid-overview.json':
g.dashboard.new(prefix + ' overview')
+ g.dashboard.withDescription('')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels([
this.grafana.rows.clientRow,
this.grafana.rows.serverRow,
])
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '-overview',
tags,
links { squidOverview+:: {} },
annotations,
timezone,
refresh,
period
),
} + if this.config.enableLokiLogs then {
'squid-logs.json':
logslib.new(
this.config.dashboardNamePrefix + ' logs',
datasourceName=this.grafana.variables.datasources.loki.name,
datasourceRegex=this.grafana.variables.datasources.loki.regex,
filterSelector=this.config.filteringSelector,
labels=this.config.groupLabels + this.config.extraLogLabels,
formatParser=null,
showLogsVolume=this.config.showLogsVolume,
)
{
dashboards+:
{
logs+:
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
},
panels+:
{
logs+:
g.panel.logs.options.withEnableLogDetails(true)
+ g.panel.logs.options.withShowTime(false)
+ g.panel.logs.options.withWrapLogMessage(false),
},
variables+: {
toArray+: [
this.grafana.variables.datasources.prometheus { hide: 2 },
],
},
}.dashboards.logs,
} else {},

applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
g.dashboard.withTags(tags)
+ g.dashboard.withUid(uid)
+ g.dashboard.withLinks(std.objectValues(links))
+ g.dashboard.withTimezone(timezone)
+ g.dashboard.withRefresh(refresh)
+ g.dashboard.time.withFrom(period)
+ g.dashboard.withVariables(vars)
+ g.dashboard.withAnnotations(std.objectValues(annotations)),
}
1 change: 0 additions & 1 deletion squid-mixin/dashboards/dashboards.libsonnet

This file was deleted.

Loading
Loading