Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fgouteroux/loki2tf
Loki YAML Prometheus Rules to Terraform HCL converter
https://github.com/fgouteroux/loki2tf
Last synced: about 7 hours ago
JSON representation
Loki YAML Prometheus Rules to Terraform HCL converter
- Host: GitHub
- URL: https://github.com/fgouteroux/loki2tf
- Owner: fgouteroux
- License: mpl-2.0
- Created: 2023-07-26T09:20:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-26T09:36:59.000Z (over 1 year ago)
- Last Synced: 2024-06-21T15:41:45.960Z (5 months ago)
- Language: Go
- Size: 74.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# loki2tf - Loki YAML Prometheus-compatible Rules to Terraform HCL converter
A tool for converting Loki Prometheus-compatible Rules (in YAML format) into HashiCorp's Terraform configuration language.
The converted `.tf` files are suitable for use with the [Terraform Loki Provider](https://registry.terraform.io/providers/fgouteroux/loki/latest/docs)
## Installation
**Pre-built Binaries**
Download Binary from GitHub [releases](https://github.com/fgouteroux/loki2tf/releases/latest) page.
## YAML to HCL
**Convert a single YAML file and write generated Terraform config to Stdout**
```
$ loki2tf -f test-fixtures/rules.yamlresource "loki_rule_group_alerting" "should_fire" {
name = "should_fire"rule {
alert = "HighPercentageError"expr = < 0.05
EOTfor = "10m"
labels = {
severity = "page"
}annotations = {
summary = "High request latency"
}
}
}resource "loki_rule_group_alerting" "credentials_leak" {
name = "credentials_leak"rule {
alert = "http-credentials-leaked"
expr = "sum by (cluster, job, pod) (count_over_time({namespace=\"prod\"} |~ \"http(s?)://(\\w+):(\\w+)@\" [5m]) > 0)"
for = "10m"labels = {
severity = "critical"
}annotations = {
message = "{{ $labels.job }} is leaking http basic auth credentials."
}
}
}resource "loki_rule_group_recording" "NginxRules" {
name = "NginxRules"rule {
record = "nginx:requests:rate1m"expr = < **NOTE** Requires a working Golang build environment.
This project uses Golang modules for dependency management, so it can be cloned outside of the `$GOPATH`.
**Clone the repository**
```
$ git clone https://github.com/fgouteroux/loki2tf.git
```**Build**
```
$ cd loki2tf
$ make build
```