Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* [CHANGE] Add overrides config to tsdb store-gateway. #167
* [CHANGE] Ingesters now default to running as `StatefulSet` with WAL enabled. It is controlled by the config `$._config.ingester_deployment_without_wal` which is `false` by default. Setting the config to `true` will yeild the old behaviour (stateless `Deployment` without WAL enabled). #72
* [CHANGE] We now allow queries that are 32 days long. For example, rate(metric[32d]). Before it was 31d. #173
* [CHANGE] Alertmanager headless service uses a different name #179
* [ENHANCEMENT] Enable support for HA in the Cortex Alertmanager #147
* [ENHANCEMENT] Support `alertmanager.fallback_config` option in the Alertmanager. #179

## 1.3.0 / 2020-08-21

Expand Down
37 changes: 32 additions & 5 deletions cortex/alertmanager.libsonnet
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
local pvc = $.core.v1.persistentVolumeClaim,
local volumeMount = $.core.v1.volumeMount,
local volume = $.core.v1.volume,
local container = $.core.v1.container,
local statefulSet = $.apps.v1.statefulSet,
local service = $.core.v1.service,
local configMap = $.core.v1.configMap,

local isHA = $._config.alertmanager.replicas > 1,
local hasFallbackConfig = std.length($._config.alertmanager.fallback_config) > 0,
local peers = if isHA then
[
'alertmanager-%d.alertmanager.%s.svc.%s.local:%s' % [i, $._config.namespace, $._config.cluster, $._config.alertmanager.gossip_port]
Expand All @@ -22,7 +26,18 @@
'alertmanager.storage.path': '/data',
'alertmanager.storage.gcs.bucketname': '%(cluster)s-cortex-%(namespace)s' % $._config,
'alertmanager.web.external-url': '%s/alertmanager' % $._config.external_url,
},
} + if hasFallbackConfig then {
'alertmanager.configs.fallback': '/configs/alertmanager_fallback_config.yaml',
} else {},

alertmanager_fallback_config_map:
if hasFallbackConfig then
configMap.new('alertmanager-fallback-config') +
configMap.withData({
'alertmanager_fallback_config.yaml': $.util.manifestYaml($._config.alertmanager.fallback_config),
})
else {},


alertmanager_pvc::
if $._config.alertmanager_enabled then
Expand All @@ -47,11 +62,16 @@
container.withArgsMixin(
$.util.mapToFlags($.alertmanager_args) +
if isHA then
['--cluster.listen-address=[$(POD_IP)]:%s' % $._config.alertmanager_gossip_port] +
['--cluster.listen-address=[$(POD_IP)]:%s' % $._config.alertmanager.gossip_port] +
['--cluster.peer=%s' % peer for peer in peers]
else [],
) +
container.withVolumeMountsMixin([volumeMount.new('alertmanager-data', '/data')]) +
container.withVolumeMountsMixin(
[volumeMount.new('alertmanager-data', '/data')] +
if hasFallbackConfig then
[volumeMount.new('alertmanager-fallback-config', '/configs')]
else []
) +
$.util.resourcesRequests('100m', '1Gi') +
$.util.readinessProbe +
$.jaeger_mixin
Expand All @@ -67,15 +87,22 @@
statefulSet.mixin.spec.selector.withMatchLabels({ name: 'alertmanager' }) +
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(900)
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(900) +
statefulSet.mixin.spec.template.spec.withVolumesMixin(
if hasFallbackConfig then
[volume.fromConfigMap('alertmanager-fallback-config', 'alertmanager-fallback-config')]
else []
)
else {},

alertmanager_service:
if $._config.alertmanager_enabled then
if isHA then
$.util.serviceFor($.alertmanager_statefulset) +
service.mixin.metadata.withName('alertmanager-headless') +
service.mixin.spec.withClusterIp('None')
else
$.util.serviceFor($.alertmanager_statefulset)
$.util.serviceFor($.alertmanager_statefulset) +
service.mixin.metadata.withName('alertmanager')
else {},
}
1 change: 1 addition & 0 deletions cortex/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
alertmanager: {
replicas: 3,
gossip_port: 9094,
fallback_config: {},
},

overrides: {
Expand Down