Giter Site home page Giter Site logo

fgouteroux / terraform-provider-mimir Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 13.0 335 KB

This terraform provider allows you to interact with grafana mimir.

Home Page: https://registry.terraform.io/providers/fgouteroux/mimir/latest/docs

License: Apache License 2.0

Go 99.57% Makefile 0.21% Shell 0.22%
grafana prometheus terraform terraform-provider grafana-mimir

terraform-provider-mimir's Introduction

Terraform provider for grafana mimir

This terraform provider allows you to interact with grafana mimir.

Currently only these components could be managed with the api:

See Mimir API Reference

Provider mimir

Example:

provider "mimir" {
  ruler_uri = "http://localhost:8080/prometheus"
  alertmanager_uri = "http://localhost:8080"
  org_id = "mytenant"
}

URI path

  • ruler_uri (default prefix: /prometheus)
  • alertmanager_uri (default prefix: /)

Warning You may check and adapt provider uri path: ruler_uri and alertmanager_uri.

Authentication

Grafana Mimir have no authentication support, so this is delegated to a reverse proxy.

See Grafana Mimir authentication and authorization

The provider support basic auth, token.

Basic auth

provider "mimir" {
  ruler_uri = "http://localhost:8080/prometheus"
  alertmanager_uri = "http://localhost:8080"
  org_id = "mytenant"
  username = "user"
  password = "password"
}

Token

provider "mimir" {
  ruler_uri = "http://localhost:8080/prometheus"
  alertmanager_uri = "http://localhost:8080"
  org_id = "mytenant"
  token = "supersecrettoken"
}

Headers

provider "mimir" {
  ruler_uri = "http://localhost:8080/prometheus"
  alertmanager_uri = "http://localhost:8080"
  org_id = "mytenant"
  header = {
    "Custom-Auth" = "Custom value"
  }
}

Resource mimir_rule_group_alerting

Example:

resource "mimir_rule_group_alerting" "test" {
  name      = "test1"
  namespace = "namespace1"
  rule {
    alert       = "HighRequestLatency"
    expr        = "job:request_latency_seconds:mean5m{job=\"myjob\"} > 0.5"
    for         = "10m"
    labels      = {
      severity = "warning"
    }
    annotations = {
      summary = "High request latency"
    }
  }
}

Resource mimir_rule_group_recording

Example:

resource "mimir_rule_group_recording" "record" {
  name         = "test1"
  namespace    = "namespace1"
  interval     = "6h"
  query_offset = "5m"
  rule {
    expr   = "sum by (job) (http_inprogress_requests)"
    record = "job:http_inprogress_requests:sum"
  }
}

Resource mimir_alertmanager_config

Notification integrations Supported: https://prometheus.io/docs/alerting/latest/configuration/#receiver

Example:

resource "mimir_alertmanager_config" "test" {

  route {
    group_by = ["..."]
    group_wait = "30s"
    group_interval = "5m"
    repeat_interval = "1h"
    receiver = "pagerduty"
    child_route {
      group_by = ["..."]
      group_wait = "30s"
      group_interval = "5m"
      repeat_interval = "1h"
      receiver = "pagerduty"
    }
  }

  receiver {
    name = "pagerduty"
    pagerduty_configs {
      routing_key = "secret"
      severity = "info"
      details = {
        environment = "test"
        platform = "sandbox"
      }
    }
  }
}

Importing existing resources

This provider supports importing existing resources into the terraform state. Import is done according to the various provider/resource configuation settings to contact the API server and obtain data.

mimir alerting rule group

To import mimir rule group alerting The id is build as <namespace>/<name>

Example:

terraform import 'mimir_rule_group_alerting.alert1' namespace1/alert1
mimir_rule_group_alerting.alert1: Importing from ID "namespace1/alert1"...
mimir_rule_group_alerting.alert1: Import prepared!
  Prepared mimir_rule_group_alerting for import
mimir_rule_group_alerting.alert1: Refreshing state... [id=namespace1/alert1]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

mimir recording rule group

To import mimir rule group recording The id is build as <namespace>/<name>

Example:

terraform import 'mimir_rule_group_recording.record1' namespace1/record1
mimir_rule_group_recording.record1: Importing from ID "namespace1/record1"...
mimir_rule_group_recording.record1: Import prepared!
  Prepared mimir_rule_group_recording for import
mimir_rule_group_recording.record1: Refreshing state... [id=namespace1/record1]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

mimir alertmanager config

To import mimir alertmanager config The id is build as <org_id>

Example:

terraform import 'mimir_alertmanager_config.test' test
mimir_alertmanager_config.test: Importing from ID "test"...
mimir_alertmanager_config.test: Import prepared!
  Prepared mimir_alertmanager_config for import
mimir_alertmanager_config.test: Refreshing state... [id=test]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Contributing

Pull requests are always welcome! Please be sure the following things are taken care of with your pull request:

  • go fmt is run before pushing
  • Be sure to add a test case for new functionality (or explain why this cannot be done)

terraform-provider-mimir's People

Contributors

adnankobir avatar arylatt avatar davidkohr avatar dracoyunho avatar fgouteroux avatar gburanov avatar github-vincent-miszczak avatar paulojmdias avatar pbarsotti-glovo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-provider-mimir's Issues

Error: Root resource was present, but now absent.

mimir_rule_group_alerting.cluster_health: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to mimir_rule_group_alerting.cluster_health, provider "provider[\"registry.terraform.io/fgouteroux/mimir\"]" produced an unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

mimir_alertmanager_config doesn't support non-configured Alertmanager

If mimir_alertmanager_config resource is deployed to a new Alertmanager instance that hasn't been configured with initial config (which is the default case ie. for Mimir Helm chart), an error is reported alertmanager is not configured. A solution to that would be to ie. manually inject some random config into Alertmanager via Mimirtool before running Terraform, however this is a bit counterproductive, because why configure something before configuration can be deployed? :D Ideally mimir_alertmanager_config would work fine against a fresh, unconfigured instance of Alertmanager.

The "old" Cortex provider's (https://registry.terraform.io/providers/inuits/cortex/latest/docs) resource cortex_alertmanager works fine against both unconfigured Cortex and Mimir in the scenario described.

One more thing - when I stumbled upon this issue, I worked through it by manually injecting some random config into Alertmanager via Mimirtool, however then stumbled upon error "invalid character 'e' in literal true (expecting 'r') which I didn't debug. Possibly it might be something going on in my config's syntax (although I copied it from provider's example). This part is just FYI.

"mimir_alertmanager_config.this.routes.child_route[*].continue" not persisted

Hi,

Every time that we do a plan and if the value of continue is true, they will always try to update without success.

I have tried to check the provider code but I haven't found any reason for this happens. If I upload the same yaml configuration with mimirtool the continue with value true will be accepted.

❯ terraform plan
module.alertmanager_config.mimir_alertmanager_config.this: Refreshing state... [id=dummy]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.alertmanager_config.mimir_alertmanager_config.this will be updated in-place
  ~ resource "mimir_alertmanager_config" "this" {
        id              = "dummy"
        # (2 unchanged attributes hidden)

      ~ route {
            # (5 unchanged attributes hidden)

          ~ child_route {
              ~ continue              = false -> true
                # (8 unchanged attributes hidden)
            }
          ~ child_route {
              ~ continue              = false -> true
                # (8 unchanged attributes hidden)
            }
        }

        # (4 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Root resource was present, but now absent.

Hi when i tried terraform apply i got this error after saying yes to the plan

mimir_rule_group_alerting.cluster_health: Creating...
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to mimir_rule_group_alerting.cluster_health, provider "provider[\"registry.terraform.io/fgouteroux/mimir\"]" produced an unexpected new value: Root resource was present, but now absent.
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
Terraform v1.1.9
on darwin_arm64
+ provider registry.terraform.io/fgouteroux/mimir v0.1.3

mimir_alertmanager_config - child routes to inherit global parameters

when working with https://registry.terraform.io/providers/fgouteroux/mimir/latest/docs/resources/alertmanager_config#child_route I noticed that the child routes seem not to inherit global settings, this unnecessarily complicates the config

example of the current requirements:

  route {
    global {
      pagerduty_url = "https://events.pagerduty.com/v2/enqueue"
      resolve_timeout = "5m"
    }
    
    group_by = ["alertname", "instance"]
    group_wait = "10s"
    group_interval = "1m"
    repeat_interval = "1h"
    receiver = "default"

    route {
      group_wait = "10s"
      group_interval = "1m"
      repeat_interval = "1h"
      receiver = "aaa"
    }
    route {
      group_wait = "10s"
      group_interval = "1m"
      repeat_interval = "1h"
      receiver = "bbb"
    }
    route {
      group_wait = "10s"
      group_interval = "1m"
      repeat_interval = "1h"
      receiver = "ccc"
    }
  }

example of config with inheriting enabled:

  route {
    global {
      pagerduty_url = "https://events.pagerduty.com/v2/enqueue"
      resolve_timeout = "5m"
    }
    
    group_by = ["alertname", "instance"]
    group_wait = "10s"
    group_interval = "1m"
    repeat_interval = "1h"
    receiver = "default"

    route {
      receiver = "aaa"
    }
    route {
      receiver = "bbb"
    }
    route {
      receiver = "ccc"
    }
  }

provider seems not to respect format_promql_expr = true

I was running the provider v0.1.5 and wanted to upgrade to a newer version.
In v0.1.7 the expression formatting was set as optional (default = false) #14
So I enabled it according to the docs https://registry.terraform.io/providers/fgouteroux/mimir/latest/docs#format_promql_expr because I didn't want changes to be made to my rules:

provider "mimir" {
  ruler_uri          = "https://some_url/prometheus"
  alertmanager_uri   = "https://some_url"
  org_id             = "fake"
  format_promql_expr = true
}

however, the provider seems not to respect this setting and tries to un-format my rules (no changes made to the code other than the provider upgrade), example:

      ~ rule {
          ~ expr   = <<-EOT
              - histogram_quantile(
              -   0.95,
              -   sum by (mode, le) (rate(some_metric[2d]))
              - )
              + histogram_quantile(0.95, sum(rate(some_metric[2d])) by (mode, le))
            EOT

I tried two versions: 0.1.7 and 0.2.5, both behave the same.

Can't find a way to set times in time_interval in hours

Hello,
Thanks for provider.
Is there anyway way we can set hours, provider documentation says start_minutes and end_minutes (Data type: number). But alertmanager documentation start_time and end_time. Can you please guid here ?

Something like

  times {
        start_time = 3  # 3:00 AM MDT
        end_time   = 21 #  9:00 PM MDT 
      }

Alertmanager times format:

 times:
    - start_time: HH:MM
      end_time: HH:MM

terraform time_interval configuration getting Error.

ERROR: Error: Cannot update alertmanager config unexpected response code '400': error validating Alertmanager config: configuration provided is empty, if you'd like to remove your configuration please use the delete configuration endpoint

time_interval {
    name = "test_mute_window_60min"
    time_intervals {
      location = "America/Denver"
      weekdays {
        begin = 0
        end   = 5
      }
      times {
        start_minute = 3
        end_minute   = 21
      }
    }
  }

alertmanager API compatiblity with Mimir 2.12

Mimir 2.12 (https://github.com/grafana/mimir/releases/tag/mimir-2.12.0) deprecated the v1 Alertmanager APIs:

Alertmanager deprecated the v1 API. All v1 API endpoints now respond with a JSON deprecation notice and a status code of 410.
All endpoints have a v2 equivalent.
The list of endpoints is:

<alertmanager-web.external-url>/api/v1/alerts
<alertmanager-web.external-url>/api/v1/receivers
<alertmanager-web.external-url>/api/v1/silence/{id}
<alertmanager-web.external-url>/api/v1/silences
<alertmanager-web.external-url>/api/v1/status

Looks like the provider still uses the v1 endpoint:

apiAlertsPath = "/api/v1/alerts"

It would be nice to support the v2 one to provide compatiblity with Mimir 2.12

Support multiple dynamic blocks

Hello!

thanks for developing this provider!

While trying to create an Alertmanager configuration I noticed that it is currently not possible to create multiple email_configs for a single receiver, or multiple time_intervals blocks per time_interval, although both would be perfectly valid according to the alertmanager config spec. By looking at the code i determined that there are multiple other types with similar restrictions.

I was wondering if there is a reason for this, seemingly arbitrary, limitation? If not please consider this a feature request. I can look into providing a corresponding Pull Request as well.

Thanks in advance!

Preservation of Formatting in Expressions

Hello,

Currently, when using the Mimir Terraform provider to write expressions, white-space characters and newlines seem to be mostly stripped out. This leads to the resulting expressions being quite difficult to read, especially when they have numerous label selectors or fields that were originally written on separate lines for better readability.

For example, consider the following expression:

sum without (
  job,
  instance,
  kubernetes_pod_name,
  kubernetes_namespace,
  ingress_controller_name,
  host,
  method,
  status_code
) (
  rate(
    http_request_duration_microseconds_sum{
      status_code=~"5.*",
      method="POST",
      kubernetes_namespace="production",
      ingress_controller_name="nginx-ingress",
      job="http-service",
      instance="us-east-1"
    }[5m]
  )
) > 10

When applying, it becomes:

sum without (job, instance, kubernetes_pod_name, kubernetes_namespace, ingress_controller_name, host, method, status_code) (
    rate(
        http_request_duration_microseconds_sum{instance="us-east-1",job="http-service",method="POST",kubernetes_namespace="production",ingress_controller_name="nginx-ingress",status_code=~"5.*"}[5m]
    )
)
>
    10

As you can see, the second version is harder to read and understand. Is there a possibility to preserve the original formatting? This would significantly improve the readability and maintainability of complex expressions.

The relevant part of the code appears to be in shared.go, as per the below link:

https://github.com/fgouteroux/terraform-provider-mimir/blob/78f3edeffad035f4ff32eaea0b623b679e1e1d54/mimir/shared.go#L129C33-L129C41

Any insights or potential workarounds for this issue would be greatly appreciated.

Thank you.

V1 api deprecation

Hello

Will you plan to update provider to be compatibile with new version of Alertmanager?
https://github.com/grafana/mimir/releases

Alertmanager deprecated the v1 API. All v1 API endpoints now respond with a JSON deprecation notice and a status code of 410.
All endpoints have a v2 equivalent.
The list of endpoints is:

<alertmanager-web.external-url>/api/v1/alerts

<alertmanager-web.external-url>/api/v1/receivers

<alertmanager-web.external-url>/api/v1/silence/{id}

<alertmanager-web.external-url>/api/v1/silences

<alertmanager-web.external-url>/api/v1/status

Datasource mimir_rule_group_recording: missing label property

When querying a mimir_rule_group_recording with labels, Terraform will crash with the following error:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: Invalid address to set: []string{"rule", "0", "labels"}
│ 
│   with data.mimir_rule_group_recording.record,
│   on main.tf line 26, in data "mimir_rule_group_recording" "record":
│   26: data "mimir_rule_group_recording" "record" {
│ 
╵

Test setup

Recording rule

Recording rule created in Grafana Cloud.
mimirtool output:

name: test-eval-group
rules:
    - record: recording_probe_success
      expr: |-
        probe_success
        + on (instance, job, probe, config_version) group_left(org_id, geohash, check_name, region, frequency)
        (
          0 * label_replace(sm_check_info{label_org_id!=""}, "org_id", "$1", "label_org_id", "(.+)")
        )        
      labels:
        recording_success_probe: probe_success

Terraform file

provider "mimir" {
  uri = "<redacted>"
  ruler_uri = "<redacted>"
  org_id = "<redacted>"
  username = "<redacted>"
  password = "<redacted>"
  debug = true
}

data "mimir_rule_group_recording" "record" {
  name      = "test-eval-group"
  namespace = "synthetic_monitoring"
}

output "rules" {
  value = data.mimir_rule_group_recording.record
}

and then launch terraform plan

Terraform debug output

HTTP/1.1 200 OK
Content-Length: 755
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
Content-Type: application/yaml
Date: Tue, 19 Mar 2024 14:14:58 GMT
Vary: Accept-Encoding
Via: 1.1 google

name: test-eval-group
rules:
    - record: recording_probe_success
      expr: |-
        probe_success
        + on (instance, job, probe, config_version) group_left(org_id, geohash, check_name, region, frequency)
        (
          0 * label_replace(sm_check_info{label_org_id!=""}, "org_id", "$1", "label_org_id", "(.+)")
        )
      labels:
        recording_success_probe: probe_success
    - record: recording_probe_success_with_hostname
      expr: |-
        recording_probe_success
        + on (instance, job, probe, config_version) group_left(hostname, geohash, check_name, region, frequency, alert_sensitivity)
        (
          0 * label_replace(sm_check_info{label_hostname!=""}, "hostname", "$1", "label_hostname", "(.+)")
        ): timestamp=2024-03-19T15:14:58.773+0100
2024-03-19T15:14:58.773+0100 [INFO]  provider.terraform-provider-mimir_v0.2.5: 2024/03/19 15:14:58 [ERROR] setting state: Invalid address to set: []string{"rule", "0", "labels"}: timestamp=2024-03-19T15:14:58.773+0100
2024-03-19T15:14:58.773+0100 [ERROR] provider.terraform-provider-mimir_v0.2.5: Response contains error diagnostic: @module=sdk.proto tf_proto_version=5.3 diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="Invalid address to set: []string{"rule", "0", "labels"}" tf_data_source_type=mimir_rule_group_recording tf_provider_addr=registry.terraform.io/fgouteroux/mimir tf_req_id=35864dcf-c7b4-2fdf-3763-c74dcc34462a @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:58 tf_rpc=ReadDataSource timestamp=2024-03-19T15:14:58.773+0100
2024-03-19T15:14:58.774+0100 [ERROR] vertex "data.mimir_rule_group_recording.record" error: Invalid address to set: []string{"rule", "0", "labels"}
2024-03-19T15:14:58.774+0100 [ERROR] vertex "data.mimir_rule_group_recording.record (expand)" error: Invalid address to set: []string{"rule", "0", "labels"}

Mimir alertmanager teams config

Hello
Nowdays the mimir alertmanager allows define webhook for MSteams can you please add it to integration to provider?
Without this i will allways ends up with error:

Error: Unsupported block type │ │ on alertmanager.tf line 238, in resource "mimir_alertmanager_config" "alert_routing": │ 238: msteams_configs { │ │ Blocks of type "msteams_configs" are not expected here.

Integration in terraform should look like this:
receiver { name = "fooo" msteams_configs { webhook_url = "some_webhook_url" } }

"receiver.opsgenie_configs.http_config.basic_auth" not persisted

Thanks for the provider.

I stumbled on the following issue. Every terraform apply the following change keeps popping up:

  ~ resource "mimir_alertmanager_config" "config" {
        id              = "anonymous"
        # (2 unchanged attributes hidden)

      ~ receiver {
            name = "default-receiver"

          ~ webhook_configs {
                # (3 unchanged attributes hidden)

              ~ http_config {
                    # (1 unchanged attribute hidden)

                  + basic_auth {
                      + password = (sensitive value)
                      + username = "perfana-api-user"
                    }
                }
            }
        }

        # (1 unchanged block hidden)
    }

It looks like receiver.opsgenie_configs.http_config.basic_auth is not properly persisted: https://registry.terraform.io/providers/fgouteroux/mimir/latest/docs/resources/alertmanager_config#nested-schema-for-receiveropsgenie_configshttp_config

fatal error: concurrent map iteration and map write

This is on OS X and happens frequently:

 The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-mimir_v0.0.5 plugin:

fatal error: concurrent map iteration and map write

goroutine 85 [running]:
runtime.throw({0x19d61d9, 0x150})
	runtime/panic.go:1198 +0x71 fp=0xc0007b3060 sp=0xc0007b3030 pc=0x10355f1
runtime.mapiternext(0x1947240)
	runtime/map.go:858 +0x4eb fp=0xc0007b30d0 sp=0xc0007b3060 pc=0x100f7cb
github.com/fgouteroux/terraform-provider-mimir/mimir.(*api_client).send_request(0xc0000fe600, {0x19b1d36, 0x2}, {0x19b0396, 0x3}, {0xc0002f0d80, 0x19bcfa6}, {0x0, 0x11}, 0x0)
	github.com/fgouteroux/terraform-provider-mimir/mimir/api_client.go:160 +0x356 fp=0xc0007b32b0 sp=0xc0007b30d0 pc=0x1805196
github.com/fgouteroux/terraform-provider-mimir/mimir.ruleAlertingRead({0x108dcca, 0x1c58480}, 0xc000138e00, {0x18bbde0, 0xc0000fe600})
	github.com/fgouteroux/terraform-provider-mimir/mimir/resource_mimir_rule_group_alerting.go:167 +0x22b fp=0xc0007b33a8 sp=0xc0007b32b0 pc=0x180b6cb
github.com/fgouteroux/terraform-provider-mimir/mimir.resourcemimirRuleGroupAlertingRead({0x1c58448, 0xc0002d1380}, 0x2459a68, {0x18bbde0, 0xc0000fe600})
	github.com/fgouteroux/terraform-provider-mimir/mimir/resource_mimir_rule_group_alerting.go:106 +0x31 fp=0xc0007b33f0 sp=0xc0007b33a8 pc=0x180a971
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000300ee0, {0x1c58480, 0xc0007ceed0}, 0xd, {0x18bbde0, 0xc0000fe600})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0x12e fp=0xc0007b3468 sp=0xc0007b33f0 pc=0x163e22e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000300ee0, {0x1c58480, 0xc0007ceed0}, 0xc000812a90, {0x18bbde0, 0xc0000fe600})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x585 fp=0xc0007b3680 sp=0xc0007b3468 pc=0x1640545
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00000c078, {0x1c583d8, 0xc000598800}, 0xc0000a8000)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x574 fp=0xc0007b37a0 sp=0xc0007b3680 pc=0x1635034
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0xc0003dd7c0, {0x1c58480, 0xc0007e21b0}, 0xc000a04180)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:746 +0x48c fp=0xc0007b3b48 sp=0xc0007b37a0 pc=0x1507fcc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x1982620, 0xc0003dd7c0}, {0x1c58480, 0xc0007e21b0}, 0xc0006c6000, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:349 +0x170 fp=0xc0007b3ba0 sp=0xc0007b3b48 pc=0x14f1930
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00024f6c0, {0x1c66dc0, 0xc000502340}, 0xc000884240, 0xc000239080, 0x222fc70, 0x0)
	google.golang.org/[email protected]/server.go:1295 +0xb03 fp=0xc0007b3e48 sp=0xc0007b3ba0 pc=0x1460ec3
google.golang.org/grpc.(*Server).handleStream(0xc00024f6c0, {0x1c66dc0, 0xc000502340}, 0xc000884240, 0x0)
	google.golang.org/[email protected]/server.go:1636 +0xa2a fp=0xc0007b3f68 sp=0xc0007b3e48 pc=0x1464fea
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:932 +0x98 fp=0xc0007b3fe0 sp=0xc0007b3f68 pc=0x145eb38
runtime.goexit()
	runtime/asm_amd64.s:1581 +0x1 fp=0xc0007b3fe8 sp=0xc0007b3fe0 pc=0x10667e1
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:930 +0x294

goroutine 1 [select]:
github.com/hashicorp/go-plugin.Serve(0xc00005a180)
	github.com/hashicorp/[email protected]/server.go:469 +0x1473
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.Serve({0x19b5279, 0xa413c20}, 0xc0003a51e0, {0x0, 0x0, 0x0})
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:311 +0xbaa
github.com/hashicorp/terraform-plugin-sdk/v2/plugin.tf5serverServe(0xc00005a120)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go:178 +0x518
github.com/hashicorp/terraform-plugin-sdk/v2/plugin.Serve(0xc00005a120)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go:118 +0x177
main.main()
	github.com/fgouteroux/terraform-provider-mimir/main.go:21 +0xda

goroutine 10 [select]:
github.com/hashicorp/go-plugin.(*gRPCBrokerServer).Recv(0x0)
	github.com/hashicorp/[email protected]/grpc_broker.go:121 +0x6d
github.com/hashicorp/go-plugin.(*GRPCBroker).Run(0xc000108780)
	github.com/hashicorp/[email protected]/grpc_broker.go:411 +0x48
created by github.com/hashicorp/go-plugin.(*GRPCServer).Init
	github.com/hashicorp/[email protected]/grpc_server.go:85 +0x469

goroutine 11 [IO wait]:
internal/poll.runtime_pollWait(0xa618fd0, 0x72)
	runtime/netpoll.go:303 +0x85
internal/poll.(*pollDesc).wait(0xc00005a720, 0xc000055000, 0x1)
	internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
	internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc00005a720, {0xc000055000, 0x1000, 0x1000})
	internal/poll/fd_unix.go:167 +0x25a
os.(*File).read(...)
	os/file_posix.go:32
os.(*File).Read(0xc0000a6158, {0xc000055000, 0x400, 0x18987a0})
	os/file.go:119 +0x5e
bufio.(*Reader).Read(0xc0002a4f40, {0xc0000f6400, 0x400, 0x0})
	bufio/bufio.go:227 +0x1b4
github.com/hashicorp/go-plugin.copyChan({0x1c71b30, 0xc0001ad3b0}, 0x0, {0x1c44fe0, 0xc0000a6158})
	github.com/hashicorp/[email protected]/grpc_stdio.go:181 +0x1f6
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
	github.com/hashicorp/[email protected]/grpc_stdio.go:37 +0xfa

goroutine 12 [IO wait]:
internal/poll.runtime_pollWait(0xa618df0, 0x72)
	runtime/netpoll.go:303 +0x85
internal/poll.(*pollDesc).wait(0xc00005a7e0, 0xc0003e5000, 0x1)
	internal/poll/fd_poll_runtime.go:84 +0x32
internal/poll.(*pollDesc).waitRead(...)
	internal/poll/fd_poll_runtime.go:89
internal/poll.(*FD).Read(0xc00005a7e0, {0xc0003e5000, 0x1000, 0x1000})
	internal/poll/fd_unix.go:167 +0x25a
os.(*File).read(...)
	os/file_posix.go:32
os.(*File).Read(0xc0000a6178, {0xc0003e5000, 0x400, 0x18987a0})
	os/file.go:119 +0x5e
bufio.(*Reader).Read(0xc0002a5740, {0xc0000f6800, 0x400, 0x0})
	bufio/bufio.go:227 +0x1b4
github.com/hashicorp/go-plugin.copyChan({0x1c71b30, 0xc0001ad3b0}, 0x0, {0x1c44fe0, 0xc0000a6178})
	github.com/hashicorp/[email protected]/grpc_stdio.go:181 +0x1f6
created by github.com/hashicorp/go-plugin.newGRPCStdioServer
	github.com/hashicorp/[email protected]/grpc_stdio.go:38 +0x188

goroutine 14 [syscall]:
os/signal.signal_recv()
	runtime/sigqueue.go:166 +0x28
os/signal.loop()
	os/signal/signal_unix.go:24 +0x19
created by os/signal.Notify.func1.1
	os/signal/signal.go:151 +0x2c

Error: The terraform-provider-mimir_v0.0.5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

How do I do nested policies more than one layer deep for the notification policies?

As the title asks, how do I do nested policies more than one layer deep for the notification policies?

With child routes, you can nest one route under another, but how would I nest another under that child route?

For example, page for prod alerts, slack for nonprod:

route = {
  receiver = "none"
  matchers = [
    severity=critical
  ]
  child_routes = [
    {
      receiver = "none"    
      matchers = [ alertname=nodeDown ]
      child_routes = [
        receiver = "page_out"
        matchers = [ environment=prod ]
       ]
      child_routes = [
        receiver = "slack_out"
        matchers = [ environment=nonprod ]
      ]
    }
}

support for labels in recording rules

Some Mimir recording rules (ie. https://github.com/grafana/mimir/blob/main/operations/mimir-mixin-compiled/rules.yaml#L328) require labels to work properly, however the provider seems not to support those?

When running the following code against the provider (version 0.0.9)

  rule {
    record = "cluster_namespace_deployment_reason:required_replicas:count"
    expr   = "ceil(quantile_over_time(0.99, sum by (cluster, namespace) (cluster_namespace_job:cortex_distributor_received_samples:rate5m)[24h:]) / 240000)"
    labels = {
      deployment = "distributor"
      reason = "sample_rate"
    }
  }

the following error appears:

│ Error: Unsupported argument
│
│   on ../some_path.tf line 592, in resource "mimir_rule_group_recording" "mimir_rules":
│  592:     labels = {
│
│ An argument named "labels" is not expected here.

Request to support HTTP_PROXY and NO_PROXY terraform workspace variables

Hello,
I truly appreciate for the Mimir Terraform provider. I'm reaching out with a feature request that I believe would greatly benefit the community as well.

Use Case: Currently, we use Grafana Cloud in conjunction with Terraform Enterprise. We're trying to set up HTTP proxy settings using the HTTP_PROXY and NO_PROXY variables in Terraform workspaces. Currently, it seems Mimir Terraform provider doesn't allow HTTP proxy settings. It would be really helpful if Mimir Terraform provider support HTTP proxy setting.

Here is my provider configuration looks like.

terraform {
  required_providers {
    mimir = {
      source  = "fgouteroux/mimir"
      version = "0.1.7"
    }
  }
}
provider "mimir" {
  ruler_uri        = "https://prometheus-us-central1.grafana.net/prometheus"  #test
  alertmanager_uri = "https://alertmanager-us-central1.grafana.net" 
  org_id           =  sandbox_test
  username         = 39909 (prometheus instance ID)
  password         = xxxxxxxxxxx
}
provider "mimir" {
  ruler_uri        = "https://prometheus-us-central1.grafana.net/prometheus" #test
  alertmanager_uri = "https://alertmanager-us-central1.grafana.net"
  org_id           = sandbox_test
  username         = 49588 (alertmanager instance ID)
  password         = xxxxxxxxxxx
}

Error creating alert rule group

Terraform 1.2.3 and same issue with 1.4.5
on darwin_arm64

  • provider registry.terraform.io/fgouteroux/mimir v0.1.3

terraform module is working as expected until 04/03/2023

2023-04-17T16:22:40.588-0700 [TRACE] NodeAbstractResouceInstance.writeResourceInstanceState: removing state object for module.alerts_cloudSQL_dev.mimir_rule_group_alerting.CloudSQL_alerts["test_dev_alert"]
2023-04-17T16:22:40.588-0700 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2023-04-17T16:22:40.588-0700 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2023-04-17T16:22:40.588-0700 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2023-04-17T16:22:40.594-0700 [ERROR] vertex "module.alerts_cloudSQL_dev.mimir_rule_group_alerting.CloudSQL_alerts["test_dev_alert"]" error: Cannot create alerting rule group 'CloudSqlAlerts_test_dev_alert' - unexpected response code '400': unable to decode rule group
2023-04-17T16:22:40.594-0700 [TRACE] vertex "module.alerts_cloudSQL_dev.mimir_rule_group_alerting.CloudSQL_alerts["test_dev_alert"]": visit complete, with errors
2023-04-17T16:22:40.594-0700 [TRACE] dag/walk: upstream of "module.alerts_cloudSQL_dev (close)" errored, so skipping
2023-04-17T16:22:40.594-0700 [TRACE] dag/walk: upstream of "provider["registry.terraform.io/fgouteroux/mimir"] (close)" errored, so skipping
2023-04-17T16:22:40.594-0700 [TRACE] dag/walk: upstream of "root" errored, so skipping
2023-04-17T16:22:40.594-0700 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2023-04-17T16:22:40.594-0700 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2023-04-17T16:22:40.594-0700 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate

│ Error: Cannot create alerting rule group 'testapp_dev' - unexpected response code '400': unable to decode rule group

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.