{"id":18834472,"url":"https://github.com/fgouteroux/loki2tf","last_synced_at":"2025-08-21T08:14:27.016Z","repository":{"id":185495365,"uuid":"670983155","full_name":"fgouteroux/loki2tf","owner":"fgouteroux","description":" Loki YAML Prometheus Rules to Terraform HCL converter ","archived":false,"fork":false,"pushed_at":"2023-07-26T09:36:59.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T12:16:41.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fgouteroux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-26T09:20:14.000Z","updated_at":"2023-10-19T15:50:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"f01051ef-32c9-4f89-afb7-5a1ced7c2f0b","html_url":"https://github.com/fgouteroux/loki2tf","commit_stats":null,"previous_names":["fgouteroux/loki2tf"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fgouteroux/loki2tf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Floki2tf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Floki2tf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Floki2tf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Floki2tf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fgouteroux","download_url":"https://codeload.github.com/fgouteroux/loki2tf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fgouteroux%2Floki2tf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271448399,"owners_count":24761438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T02:12:35.243Z","updated_at":"2025-08-21T08:14:26.990Z","avatar_url":"https://github.com/fgouteroux.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# loki2tf - Loki YAML Prometheus-compatible Rules to Terraform HCL converter\n\nA tool for converting Loki Prometheus-compatible Rules (in YAML format) into HashiCorp's Terraform configuration language.\n\nThe converted `.tf` files are suitable for use with the [Terraform Loki Provider](https://registry.terraform.io/providers/fgouteroux/loki/latest/docs)\n\n\n## Installation\n\n**Pre-built Binaries**\n\nDownload Binary from GitHub [releases](https://github.com/fgouteroux/loki2tf/releases/latest) page.\n\n\n## YAML to HCL\n\n**Convert a single YAML file and write generated Terraform config to Stdout**\n\n```\n$ loki2tf -f test-fixtures/rules.yaml\n\nresource \"loki_rule_group_alerting\" \"should_fire\" {\n  name = \"should_fire\"\n\n  rule {\n    alert = \"HighPercentageError\"\n\n    expr = \u003c\u003cEOT\nsum(rate({app=\"foo\", env=\"production\"} |= \"error\" [5m])) by (job)\n  /\nsum(rate({app=\"foo\", env=\"production\"}[5m])) by (job)\n  \u003e 0.05\nEOT\n\n    for = \"10m\"\n\n    labels = {\n      severity = \"page\"\n    }\n\n    annotations = {\n      summary = \"High request latency\"\n    }\n  }\n}\n\nresource \"loki_rule_group_alerting\" \"credentials_leak\" {\n  name = \"credentials_leak\"\n\n  rule {\n    alert = \"http-credentials-leaked\"\n    expr  = \"sum by (cluster, job, pod) (count_over_time({namespace=\\\"prod\\\"} |~ \\\"http(s?)://(\\\\w+):(\\\\w+)@\\\" [5m]) \u003e 0)\"\n    for   = \"10m\"\n\n    labels = {\n      severity = \"critical\"\n    }\n\n    annotations = {\n      message = \"{{ $labels.job }} is leaking http basic auth credentials.\"\n    }\n  }\n}\n\nresource \"loki_rule_group_recording\" \"NginxRules\" {\n  name = \"NginxRules\"\n\n  rule {\n    record = \"nginx:requests:rate1m\"\n\n    expr = \u003c\u003cEOT\nsum(\n  rate({container=\"nginx\"}[1m])\n)\nEOT\n\n    labels = {\n      cluster = \"us-central1\"\n    }\n  }\n}\n\n```\n\n**Convert a single YAML file and write output to file**\n\n```\n$ loki2tf -f test-fixtures/rules.yaml -o rules.tf\n```\n\n**Convert a directory of Loki YAML files and write output to stdout**\n\n```\n$ loki2tf -f test-fixtures/\n```\n\n**Convert a directory of Loki YAML files and write output to file**\n\n```\n$ loki2tf -f test-fixtures/ -o /tmp/rules.tf\n```\n\n## HCL to YAML\n\n**Convert a single HCL file and write yaml output to file**\n\n```\n$ loki2tf -r -f test-fixtures/rules.tf -o /tmp/rules.yaml\n```\n\n**Convert a directory of Loki HCL files to YAML file**\n\n```\n$ loki2tf -r -f test-fixtures -o /tmp/rules.yaml\n\n```\n\n## Building\n\n\u003e **NOTE** Requires a working Golang build environment.\n\nThis project uses Golang modules for dependency management, so it can be cloned outside of the `$GOPATH`.\n\n**Clone the repository**\n\n```\n$ git clone https://github.com/fgouteroux/loki2tf.git\n```\n\n**Build**\n\n```\n$ cd loki2tf\n$ make build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgouteroux%2Floki2tf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgouteroux%2Floki2tf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgouteroux%2Floki2tf/lists"}