Skip to content

Commit 3f68b34

Browse files
committed
Grafana alloy modules
0 parents  commit 3f68b34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4374
-0
lines changed

.README.head.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Grafana Alloy Terraform module
2+
3+
## Usage
4+
5+
```
6+
module "grafana_agent" {
7+
source = "..."
8+
version = "..."
9+
10+
kubernetes_cluster_name = "somecluster"
11+
kubernetes_namespace = "cluster-apps"
12+
13+
agent_name = "clustered"
14+
clustering_enabled = true
15+
replicas = 3
16+
17+
config = [<<-EOF
18+
k8s_pods "my" {
19+
metrics_output = prometheus.remote_write.default.receiver
20+
}
21+
22+
k8s_services "my" {
23+
metrics_output = prometheus.remote_write.default.receiver
24+
}
25+
26+
k8s_cadvisor "my" {
27+
metrics_output = prometheus.remote_write.default.receiver
28+
}
29+
30+
k8s_kubelet "my" {
31+
metrics_output = prometheus.remote_write.default.receiver
32+
}
33+
EOF
34+
]
35+
36+
metrics = {
37+
endpoint = "https://mimir.example.com:443/api/v1/push"
38+
}
39+
}
40+
```
41+
42+
### OTel example
43+
44+
```
45+
module "grafana_agent" {
46+
source = "..."
47+
version = "..."
48+
49+
kubernetes_cluster_name = "somecluster"
50+
kubernetes_namespace = "cluster-apps"
51+
52+
agent_name = "otel"
53+
54+
config = [<<-EOF
55+
otel_process "my" {
56+
metrics_output = prometheus.remote_write.default.receiver
57+
traces_output = otelcol.exporter.otelhttp.default.receiver
58+
}
59+
EOF
60+
]
61+
62+
metrics = {
63+
endpoint = "https://mimir.example.com:443/api/v1/push"
64+
}
65+
66+
otel = {
67+
enabled = true
68+
endpoint = "https://tempo.example.com:443"
69+
}
70+
}
71+
```
72+
73+
NOTE: OTel components are not cluster-capable and some require single point of processing (ie. traces)
74+
75+
For working examples, look into the submodules
76+
77+
### Kubernetes usage resources
78+
79+
```
80+
agent_resources = {
81+
requests = {
82+
cpu = "100m"
83+
memory = "100Mi"
84+
}
85+
limits = {
86+
cpu = "1"
87+
memory = "1Gi"
88+
}
89+
}
90+
```
91+
92+
Please note, when limits are undefined, requests values are used for limits too.
93+
94+
---

.github/workflows/check.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Check
2+
on:
3+
push:
4+
branches:
5+
- "**"
6+
7+
jobs:
8+
fmt:
9+
name: Terraform Format
10+
runs-on: ubuntu-latest
11+
container:
12+
image: ghcr.io/cookielab/container-image-terraform:1.10
13+
options: --user root
14+
credentials:
15+
username: ${{ github.actor }}
16+
password: ${{ secrets.GITHUB_TOKEN }}
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
- name: Check Terraform format
21+
run: terraform fmt -check=true
22+
lint:
23+
name: TF Lint
24+
runs-on: ubuntu-latest
25+
container:
26+
image: ghcr.io/cookielab/container-image-terraform:1.9
27+
options: --user root
28+
credentials:
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
- name: Check TF lint
35+
run: tflint
36+
validate:
37+
name: Terraform Validate
38+
runs-on: ubuntu-latest
39+
container:
40+
image: ghcr.io/cookielab/container-image-terraform:1.9
41+
options: --user root
42+
credentials:
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v4
48+
- name: Inject additional provider
49+
uses: "finnp/create-file-action@master"
50+
env:
51+
FILE_NAME: "test_injection.tf"
52+
FILE_DATA: |
53+
provider "aws" {
54+
alias = "us_east_1"
55+
}
56+
- name: Terraform init
57+
run: terraform init
58+
- name: Terraform validate
59+
run: terraform validate

.github/workflows/package.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Terraform Package
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
package:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Terraform
18+
uses: hashicorp/setup-terraform@v3
19+
with:
20+
terraform_version: "1.10.0"
21+
22+
- name: Initialize Terraform
23+
run: |
24+
terraform init
25+
26+
- name: Validate Terraform
27+
run: |
28+
terraform validate
29+
30+
- name: Package Module
31+
run: |
32+
zip -r terraform-kubernetes-grafana-alloy.zip ./* \
33+
-x '*.git*' \
34+
-x '*.github*' \
35+
-x '*.gitignore'
36+
37+
- name: Get Version
38+
id: get_version
39+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
40+
41+
- name: Upload Package
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: terraform-kubernetes-grafana-alloy-${{ steps.get_version.outputs.VERSION }}
45+
path: terraform-kubernetes-grafana-alloy.zip
46+
47+
- name: Create Release
48+
uses: softprops/action-gh-release@v1
49+
with:
50+
files: terraform-kubernetes-grafana-alloy.zip
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright © 2025 Cookielab s.r.o.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

0 commit comments

Comments
 (0)