Skip to content

Commit 43cd02d

Browse files
authored
Merge pull request #3 from kabisa/renovate/configure
Configure Renovate
2 parents 75927ae + f032e59 commit 43cd02d

17 files changed

+846
-5
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Generate terraform docs
2+
3+
on:
4+
push:
5+
# don't run when we push a tag
6+
tags-ignore:
7+
- '*'
8+
# don't run when we merge to main
9+
# the action should have run already
10+
branches-ignore:
11+
- 'main'
12+
jobs:
13+
pre-commit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: terraform-linters/setup-tflint@v2
17+
name: Setup TFLint
18+
with:
19+
tflint_version: v0.38.1
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
22+
- uses: pre-commit/[email protected]
23+
# pre-commit fails if it changed files
24+
# we want to go on
25+
continue-on-error: true
26+
- uses: pre-commit/[email protected]
27+
- uses: EndBug/add-and-commit@v9
28+
with:
29+
default_author: github_actions

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ repos:
55
- id: terraform-fmt
66
- id: terraform-validate
77
- id: tflint
8-
- id: shellcheck
8+
- repo: https://github.com/kabisa/terraform-datadog-pre-commit-hook
9+
rev: "1.3.6"
10+
hooks:
11+
- id: terraform-datadog-docs
12+
args:
13+
- "."

.terraform.lock.hcl

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 174 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,178 @@
1-
# terraform-module-template
21

3-
## Getting Started
2+
![Datadog](https://imgix.datadoghq.com/img/about/presskit/logo-v/dd_vertical_purple.png)
43

5-
Pre-commit:
4+
[//]: # (This file is generated. Do not edit, module description can be added by editing / creating module_description.md)
5+
6+
# Terraform module for Datadog Apache Server
7+
8+
This module is part of a larger suite of modules that provide alerts in Datadog.
9+
Other modules can be found on the [Terraform Registry](https://registry.terraform.io/search/modules?namespace=kabisa&provider=datadog)
10+
11+
We have two base modules we use to standardise development of our Monitor Modules:
12+
- [generic monitor](https://github.com/kabisa/terraform-datadog-generic-monitor) Used in 90% of our alerts
13+
- [service check monitor](https://github.com/kabisa/terraform-datadog-service-check-monitor)
14+
15+
Modules are generated with this tool: https://github.com/kabisa/datadog-terraform-generator
16+
17+
18+
[Module Variables](#module-variables)
19+
20+
Monitors:
21+
22+
| Monitor name | Default enabled | Priority | Query |
23+
|-----------------|------|----|------------------------|
24+
| [CPU Load](#cpu-load) | True | 3 | `avg(${var.cpu_usage_evaluation_period}):avg:apache.performance.cpu_load{${local.cpu_usage_filter}} by {service,host} > ${var.cpu_usage_critical}` |
25+
| [Traffic](#traffic) | True | 3 | `avg(last_15m):avg:apache.net.bytes_per_s{tag:xxx} by {service,host} > 100000` |
26+
| [Vhost Request Rate](#vhost-request-rate) | True | 3 | `avg(last_30m):per_minute(avg:apache.net.hits{tag:xxx,env:${var.env}} by {service,host}) > ` |
27+
| [Vhost Workers](#vhost-workers) | True | 2 | `max(last_15m):min:apache.performance.idle_workers{tag:xxx} by {service,host} < 1` |
28+
29+
# Getting started developing
30+
[pre-commit](http://pre-commit.com/) was used to do Terraform linting and validating.
31+
32+
Steps:
633
- Install [pre-commit](http://pre-commit.com/). E.g. `brew install pre-commit`.
7-
- Run `pre-commit install` in this repo. (Every time you cloud a repo with pre-commit enabled you will need to run the pre-commit install command)
34+
- Run `pre-commit install` in this repo. (Every time you clone a repo with pre-commit enabled you will need to run the pre-commit install command)
835
- That’s it! Now every time you commit a code change (`.tf` file), the hooks in the `hooks:` config `.pre-commit-config.yaml` will execute.
36+
37+
## CPU Load
38+
39+
Query:
40+
```terraform
41+
avg(${var.cpu_usage_evaluation_period}):avg:apache.performance.cpu_load{${local.cpu_usage_filter}} by {service,host} > ${var.cpu_usage_critical}
42+
```
43+
44+
| variable | default | required | description |
45+
|-----------------------------|----------|----------|----------------------------------|
46+
| cpu_usage_enabled | True | No | |
47+
| cpu_usage_warning | 75 | No | |
48+
| cpu_usage_critical | 80 | No | |
49+
| cpu_usage_evaluation_period | last_15m | No | |
50+
| cpu_usage_note | "" | No | |
51+
| cpu_usage_docs | "" | No | |
52+
| cpu_usage_filter_override | "" | No | |
53+
| cpu_usage_alerting_enabled | True | No | |
54+
| cpu_usage_no_data_timeframe | None | No | |
55+
| cpu_usage_notify_no_data | False | No | |
56+
| cpu_usage_ok_threshold | None | No | |
57+
| cpu_usage_name_prefix | None | No | |
58+
| cpu_usage_name_suffix | None | No | |
59+
| cpu_usage_priority | 3 | No | Number from 1 (high) to 5 (low). |
60+
61+
62+
## Traffic
63+
64+
Query:
65+
```terraform
66+
avg(last_15m):avg:apache.net.bytes_per_s{tag:xxx} by {service,host} > 100000
67+
```
68+
69+
| variable | default | required | description |
70+
|---------------------------|----------|----------|----------------------------------|
71+
| traffic_enabled | True | No | |
72+
| traffic_warning | 75000 | No | |
73+
| traffic_critical | 100000 | No | |
74+
| traffic_evaluation_period | last_15m | No | |
75+
| traffic_note | "" | No | |
76+
| traffic_docs | "" | No | |
77+
| traffic_filter_override | "" | No | |
78+
| traffic_alerting_enabled | True | No | |
79+
| traffic_no_data_timeframe | None | No | |
80+
| traffic_notify_no_data | False | No | |
81+
| traffic_ok_threshold | None | No | |
82+
| traffic_name_prefix | None | No | |
83+
| traffic_name_suffix | None | No | |
84+
| traffic_priority | 3 | No | Number from 1 (high) to 5 (low). |
85+
86+
87+
## Vhost Availability
88+
89+
This monitor raises alerts when it cannot successfully connect to an apache vhost.
90+
91+
| variable | default | required | description |
92+
|--------------------------------------|------------------------------------------|----------|----------------------------------|
93+
| vhost_availability_enabled | True | No | |
94+
| vhost_availability_freshness_cycles | 3 | No | |
95+
| vhost_availability_warning | 2 | No | |
96+
| vhost_availability_critical | 3 | No | |
97+
| vhost_availability_evaluation_period | last_5m | No | |
98+
| vhost_availability_note | "" | No | |
99+
| vhost_availability_docs | This monitor raises alerts when it cannot successfully connect to an apache vhost. | No | |
100+
| vhost_availability_include_tags | [] | No | |
101+
| vhost_availability_exclude_tags | [] | No | |
102+
| vhost_availability_filter_override | "" | No | |
103+
| vhost_availability_alerting_enabled | True | No | |
104+
| vhost_availability_no_data_timeframe | 0 | No | |
105+
| vhost_availability_notify_no_data | False | No | |
106+
| vhost_availability_ok_threshold | 1 | No | |
107+
| vhost_availability_name_prefix | "" | No | |
108+
| vhost_availability_name_suffix | "" | No | |
109+
| vhost_availability_priority | 2 | No | Number from 1 (high) to 5 (low). |
110+
| vhost_require_full_window | False | No | |
111+
112+
113+
## Vhost Request Rate
114+
115+
Query:
116+
```terraform
117+
avg(last_30m):per_minute(avg:apache.net.hits{tag:xxx,env:${var.env}} by {service,host}) >
118+
```
119+
120+
| variable | default | required | description |
121+
|--------------------------------------|----------|----------|-------------------------------------------------------|
122+
| vhost_request_rate_enabled | True | No | |
123+
| vhost_request_rate_warning | None | No | |
124+
| vhost_request_rate_critical | | Yes | |
125+
| vhost_request_rate_evaluation_period | last_30m | No | |
126+
| vhost_request_rate_note | "" | No | |
127+
| vhost_request_rate_docs | "" | No | |
128+
| vhost_request_rate_filter_override | "" | No | |
129+
| vhost_request_rate_alerting_enabled | True | No | |
130+
| vhost_request_rate_no_data_timeframe | None | No | |
131+
| vhost_request_rate_notify_no_data | False | No | |
132+
| vhost_request_rate_ok_threshold | None | No | |
133+
| vhost_request_rate_name_prefix | None | No | |
134+
| vhost_request_rate_name_suffix | None | No | |
135+
| vhost_request_rate_priority | 3 | No | Number from 1 (high) to 5 (low). |
136+
| vhost_request_new_group_delay | 300 | No | Time (in seconds) to skip evaluations for new groups. |
137+
138+
139+
## Vhost Workers
140+
141+
Query:
142+
```terraform
143+
max(last_15m):min:apache.performance.idle_workers{tag:xxx} by {service,host} < 1
144+
```
145+
146+
| variable | default | required | description |
147+
|---------------------------------|----------|----------|----------------------------------|
148+
| vhost_workers_enabled | True | No | |
149+
| vhost_workers_warning | 5 | No | |
150+
| vhost_workers_critical | 1 | No | |
151+
| vhost_workers_evaluation_period | last_15m | No | |
152+
| vhost_workers_note | "" | No | |
153+
| vhost_workers_docs | "" | No | |
154+
| vhost_workers_filter_override | "" | No | |
155+
| vhost_workers_alerting_enabled | True | No | |
156+
| vhost_workers_no_data_timeframe | None | No | |
157+
| vhost_workers_notify_no_data | False | No | |
158+
| vhost_workers_ok_threshold | None | No | |
159+
| vhost_workers_name_prefix | None | No | |
160+
| vhost_workers_name_suffix | None | No | |
161+
| vhost_workers_priority | 2 | No | Number from 1 (high) to 5 (low). |
162+
163+
164+
## Module Variables
165+
166+
| variable | default | required | description |
167+
|----------------------|----------|----------|--------------|
168+
| filter_str | | Yes | |
169+
| env | | Yes | |
170+
| service | | Yes | |
171+
| service_display_name | None | No | |
172+
| notification_channel | | Yes | |
173+
| additional_tags | [] | No | |
174+
| locked | False | No | |
175+
| name_prefix | "" | No | |
176+
| name_suffix | "" | No | |
177+
178+

cpu-load-variables.tf

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
variable "cpu_usage_enabled" {
2+
type = bool
3+
default = true
4+
}
5+
6+
variable "cpu_usage_warning" {
7+
type = number
8+
default = 75
9+
}
10+
11+
variable "cpu_usage_critical" {
12+
type = number
13+
default = 80
14+
}
15+
16+
variable "cpu_usage_evaluation_period" {
17+
type = string
18+
default = "last_15m"
19+
}
20+
21+
variable "cpu_usage_note" {
22+
type = string
23+
default = ""
24+
}
25+
26+
variable "cpu_usage_docs" {
27+
type = string
28+
default = ""
29+
}
30+
31+
variable "cpu_usage_filter_override" {
32+
type = string
33+
default = ""
34+
}
35+
36+
variable "cpu_usage_alerting_enabled" {
37+
type = bool
38+
default = true
39+
}
40+
41+
variable "cpu_usage_no_data_timeframe" {
42+
type = number
43+
default = null
44+
}
45+
46+
variable "cpu_usage_notify_no_data" {
47+
type = bool
48+
default = false
49+
}
50+
51+
variable "cpu_usage_ok_threshold" {
52+
type = number
53+
default = null
54+
}
55+
56+
variable "cpu_usage_name_prefix" {
57+
type = string
58+
default = null
59+
}
60+
61+
variable "cpu_usage_name_suffix" {
62+
type = string
63+
default = null
64+
}
65+
66+
variable "cpu_usage_priority" {
67+
description = "Number from 1 (high) to 5 (low)."
68+
69+
type = number
70+
default = 3
71+
}

cpu-load.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
locals {
2+
cpu_usage_filter = coalesce(
3+
var.cpu_usage_filter_override,
4+
var.filter_str
5+
)
6+
}
7+
8+
module "cpu_usage" {
9+
source = "kabisa/generic-monitor/datadog"
10+
version = "1.0.0"
11+
12+
name = "Apache - CPU Load"
13+
query = "avg(${var.cpu_usage_evaluation_period}):avg:apache.performance.cpu_load{${local.cpu_usage_filter}} by {service,host} > ${var.cpu_usage_critical}"
14+
alert_message = "Apache CPU Load ({{value}}) for ${var.service} > {{threshold}} "
15+
recovery_message = "Apache CPU Load for ${var.service} has recovered"
16+
17+
# module level vars
18+
env = var.env
19+
service = var.service
20+
service_display_name = var.service_display_name
21+
notification_channel = var.notification_channel
22+
additional_tags = var.additional_tags
23+
locked = var.locked
24+
name_prefix = var.name_prefix
25+
name_suffix = var.name_suffix
26+
27+
# monitor level vars
28+
enabled = var.cpu_usage_enabled
29+
alerting_enabled = var.cpu_usage_alerting_enabled
30+
warning_threshold = var.cpu_usage_warning
31+
critical_threshold = var.cpu_usage_critical
32+
priority = var.cpu_usage_priority
33+
docs = var.cpu_usage_docs
34+
note = var.cpu_usage_note
35+
}

provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
terraform {
22
required_providers {
3+
datadog = {
4+
source = "DataDog/datadog"
5+
version = "~> 3.12"
6+
}
37
}
48
}

renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base"
5+
]
6+
}

0 commit comments

Comments
 (0)