2 # The "region" parameter specifies the region in which to execute the job.
3 # If omitted, this inherits the default region name of "global".
6 # The "datacenters" parameter specifies the list of datacenters which should
7 # be considered when placing this task. This must be provided.
8 datacenters = "${datacenters}"
10 # The "type" parameter controls the type of job, which impacts the scheduler's
11 # decision on placement. This configuration is optional and defaults to
12 # "service". For a full list of job types and their differences, please see
13 # the online documentation.
15 # For more information, please see the online documentation at:
17 # https://www.nomadproject.io/docs/jobspec/schedulers
22 # The "max_parallel" parameter specifies the maximum number of updates to
23 # perform in parallel. In this case, this specifies to update a single task
27 health_check = "checks"
29 # The "min_healthy_time" parameter specifies the minimum time the allocation
30 # must be in the healthy state before it is marked as healthy and unblocks
31 # further allocations from being updated.
32 min_healthy_time = "10s"
34 # The "healthy_deadline" parameter specifies the deadline in which the
35 # allocation must be marked as healthy after which the allocation is
36 # automatically transitioned to unhealthy. Transitioning to unhealthy will
37 # fail the deployment and potentially roll back the job if "auto_revert" is
39 healthy_deadline = "3m"
41 # The "progress_deadline" parameter specifies the deadline in which an
42 # allocation must be marked as healthy. The deadline begins when the first
43 # allocation for the deployment is created and is reset whenever an allocation
44 # as part of the deployment transitions to a healthy state. If no allocation
45 # transitions to the healthy state before the progress deadline, the
46 # deployment is marked as failed.
47 progress_deadline = "10m"
50 # The "canary" parameter specifies that changes to the job that would result
51 # in destructive updates should create the specified number of canaries
52 # without stopping any previous allocations. Once the operator determines the
53 # canaries are healthy, they can be promoted which unblocks a rolling update
54 # of the remaining allocations at a rate of "max_parallel".
56 # Further, setting "canary" equal to the count of the task group allows
57 # blue/green deployments. When the job is updated, a full set of the new
58 # version is deployed and upon promotion the old version is stopped.
61 # Specifies if the job should auto-promote to the canary version when all
62 # canaries become healthy during a deployment. Defaults to false which means
63 # canaries must be manually updated with the nomad deployment promote
67 # The "auto_revert" parameter specifies if the job should auto-revert to the
68 # last stable job on deployment failure. A job is marked as stable if all the
69 # allocations as part of its deployment were marked healthy.
74 # The "group" stanza defines a series of tasks that should be co-located on
75 # the same Nomad client. Any task within a group will be placed on the same
78 # For more information and examples on the "group" stanza, please see
79 # the online documentation at:
81 # https://www.nomadproject.io/docs/job-specification/group
83 group "prod-group1-${service_name}" {
84 # The "count" parameter specifies the number of the task groups that should
85 # be running under this group. This value must be non-negative and defaults
87 count = ${group_count}
89 # The constraint allows restricting the set of eligible nodes. Constraints
90 # may filter on attributes or client metadata.
92 # For more information and examples on the "volume" stanza, please see
93 # the online documentation at:
95 # https://www.nomadproject.io/docs/job-specification/constraint
98 attribute = "$${attr.cpu.arch}"
103 # The "task" stanza creates an individual unit of work, such as a Docker
104 # container, web application, or batch processing.
106 # For more information and examples on the "task" stanza, please see
107 # the online documentation at:
109 # https://www.nomadproject.io/docs/job-specification/task
111 task "prod-task1-${service_name}" {
112 # The "driver" parameter specifies the task driver that should be used to
116 %{ if use_vault_provider }
118 policies = "${vault_kv_policy_name}"
122 # The "config" stanza specifies the driver configuration, which is passed
123 # directly to the driver to start the task. The details of configurations
124 # are specific to each driver, so please see specific driver
125 # documentation for more information.
127 command = "local/alertmanager-${version}.linux-amd64/alertmanager"
129 "--config.file=secrets/alertmanager.yml"
133 # The artifact stanza instructs Nomad to fetch and unpack a remote resource,
134 # such as a file, tarball, or binary. Nomad downloads artifacts using the
135 # popular go-getter library, which permits downloading artifacts from a
136 # variety of locations using a URL as the input source.
138 # For more information and examples on the "artifact" stanza, please see
139 # the online documentation at:
141 # https://www.nomadproject.io/docs/job-specification/artifact
147 # The "template" stanza instructs Nomad to manage a template, such as
148 # a configuration file or script. This template can optionally pull data
149 # from Consul or Vault to populate runtime configuration data.
151 # For more information and examples on the "template" stanza, please see
152 # the online documentation at:
154 # https://www.nomadproject.io/docs/job-specification/template
158 change_signal = "SIGINT"
159 destination = "secrets/alertmanager.yml"
160 left_delimiter = "{{{"
161 right_delimiter = "}}}"
164 # The API URL to use for Slack notifications.
165 slack_api_url: '${slack_api_url}'
167 # The directory from which notification templates are read.
169 - '/etc/alertmanager/template/*.tmpl'
172 # # CA certificate to validate the server certificate with.
173 # ca_file: <filepath> ]
175 # # Certificate and key files for client cert authentication to the server.
176 # cert_file: <filepath>
177 # key_file: <filepath>
179 # # ServerName extension to indicate the name of the server.
180 # # http://tools.ietf.org/html/rfc4366#section-3.1
181 # server_name: <string>
183 # # Disable validation of the server certificate.
184 # insecure_skip_verify: true
186 # The root route on which each incoming alert enters.
188 receiver: '${default_receiver}'
190 # The labels by which incoming alerts are grouped together. For example,
191 # multiple alerts coming in for cluster=A and alertname=LatencyHigh would
192 # be batched into a single group.
194 # To aggregate by all possible labels use '...' as the sole label name.
195 # This effectively disables aggregation entirely, passing through all
196 # alerts as-is. This is unlikely to be what you want, unless you have
197 # a very low alert volume or your upstream notification system performs
198 # its own grouping. Example: group_by: [...]
199 group_by: ['alertname', 'cluster', 'service']
201 # When a new group of alerts is created by an incoming alert, wait at
202 # least 'group_wait' to send the initial notification.
203 # This way ensures that you get multiple alerts for the same group that start
204 # firing shortly after another are batched together on the first
208 # When the first notification was sent, wait 'group_interval' to send a batch
209 # of new alerts that started firing for that group.
212 # If an alert has successfully been sent, wait 'repeat_interval' to
216 # All the above attributes are inherited by all child routes and can
217 # overwritten on each.
218 # The child route trees.
220 # This routes performs a regular expression match on alert labels to
221 # catch alerts that are related to a list of services.
224 receiver: ${default_receiver}
225 # The service has a sub-route for critical alerts, any alerts
226 # that do not match, i.e. severity != critical, fall-back to the
227 # parent node and are sent to 'team-X-mails'
231 receiver: '${default_receiver}'
233 # Inhibition rules allow to mute a set of alerts given that another alert is
235 # We use this to mute any warning-level notifications if the same alert is
242 # Apply inhibition if the alertname is the same.
244 # If all label names listed in `equal` are missing
245 # from both the source and target alerts,
246 # the inhibition rule will apply!
247 equal: ['alertname', 'cluster', 'service']
250 - name: '${default_receiver}'
252 - channel: '#${slack_channel}'
254 icon_url: https://avatars3.githubusercontent.com/u/3380462
256 [{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}
257 {{- if gt (len .CommonLabels) (len .GroupLabels) -}}
259 {{- with .CommonLabels.Remove .GroupLabels.Names }}
260 {{- range $index, $label := .SortedPairs -}}
261 {{ if $index }}, {{ end }}
262 {{- $label.Name }}="{{ $label.Value -}}"
269 *Alert:* {{ .Annotations.summary }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
271 *Description:* {{ .Annotations.description }}
274 {{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
280 # The service stanza instructs Nomad to register a service with Consul.
282 # For more information and examples on the "task" stanza, please see
283 # the online documentation at:
285 # https://www.nomadproject.io/docs/job-specification/service
288 name = "${service_name}"
289 port = "${service_name}"
290 tags = [ "${service_name}$${NOMAD_ALLOC_INDEX}" ]
292 name = "Alertmanager Check Live"
300 # The "resources" stanza describes the requirements a task needs to
301 # execute. Resource requirements include memory, network, cpu, and more.
302 # This ensures the task will execute on a machine that contains enough
305 # For more information and examples on the "resources" stanza, please see
306 # the online documentation at:
308 # https://www.nomadproject.io/docs/job-specification/resources
313 # The network stanza specifies the networking requirements for the task
314 # group, including the network mode and port allocations. When scheduling
315 # jobs in Nomad they are provisioned across your fleet of machines along
316 # with other jobs and services. Because you don't know in advance what host
317 # your job will be provisioned on, Nomad will provide your tasks with
318 # network configuration when they start up.
320 # For more information and examples on the "template" stanza, please see
321 # the online documentation at:
323 # https://www.nomadproject.io/docs/job-specification/network
326 port "${service_name}" {