Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elasticsearch_opensearch_monitor not updating ui_metadata property in OpenSearch #310

Open
leolorenzoluis opened this issue Aug 30, 2022 · 1 comment

Comments

@leolorenzoluis
Copy link

leolorenzoluis commented Aug 30, 2022

Given the follwing code:

resource "elasticsearch_opensearch_monitor" "test {
  body = <<EOF
{
  "name": "${lookup(var.open_search_monitor_config, "name")}",
  "type": "${lookup(var.open_search_monitor_config, "type")}",
  "monitor_type": "${lookup(var.open_search_monitor_config, "monitor_type")}",
  "enabled": false,
  "schedule": {
    "period": {
      "unit": "MINUTES",
      "interval": 1
    }
  },
  "inputs": [
    {
      "search": {
        "indices": ["logs-aws-*"],
        "query": {
          "size": 0,
          "aggregations": {},
          "query": {
            "bool": {
              "filter": [
                        {
                           "range": {
                              "Created At": {
                                 "from": "{{period_end}}||-1h",
                                 "to": "{{period_end}}",
                                 "include_lower": true,
                                 "include_upper": true,
                                 "format": "epoch_millis",
                                 "boost": 1
                              }
                           }
                        }
                     ],
                     "adjust_pure_negative": true,
                     "boost": 1
                  }
               }
            }
         }
      }
   ],
  "triggers": [
    {
      "query_level_trigger": {
        "id": "queryId",
        "name": "${lookup(var.open_search_monitor_config, "trigger_name")}",
        "severity": "2",
        "condition": {
          "script": {
            "source": "ctx.results[0].hits.total.value > 0",
            "lang": "painless"
          }
        },
        "actions": [
          {
            "id": "alert",
            "name": "send-sns-alert-0",
            "destination_id": "${elasticsearch_opensearch_destination.opensearch-alert-destination.id}",
            "message_template": {
              "source": "Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.\n  - Trigger: {{ctx.trigger.name}}\n  - Severity: {{ctx.trigger.severity}}\n  - Period start: {{ctx.periodStart}}\n  - Period end: {{ctx.periodEnd}}",
              "lang": "mustache"
            },
            "throttle_enabled": false,
            "subject_template": {
              "source": "HUB Alerts-High",
              "lang": "mustache"
            }
          }
        ]
      }
    }
  ],
   "ui_metadata": {
      "monitor_type": "query_level_monitor",
      "schedule": {
         "cronExpression": "0 */1 * * *",
         "daily": 0,
         "frequency": "interval",
         "monthly": {
            "type": "day",
            "day": 1
         },
         "period": {
            "interval": 1,
            "unit": "MINUTES"
         },
         "timezone": null,
         "weekly": {
            "mon": false,
            "tue": false,
            "wed": false,
            "thur": false,
            "fri": false,
            "sat": false,
            "sun": false
         }
      },
      "search": {
         "aggregations": [],
         "bucketUnitOfTime": "h",
         "bucketValue": 1,
         "groupBy": [],
         "searchType": "query",
         "timeField": "",
         "where": {
            "fieldName": [],
            "fieldRangeEnd": 0,
            "fieldRangeStart": 0,
            "fieldValue": "",
            "operator": "is"
         }
      }
   }
}

it looks like the provider does not update the ui_metadataproperly. Tried matching the order of json properties thinking diff might be different what the Read vs it sees? Not sure.

Two scenarios happening:

  1. It creates the resource initially, but when you plan again it'll think those are updated values even if there are no actual changes
  2. It creates the resources initially. Any succeeding updates persists in OpenSearch but provider thinks it's still an update.

Hence I think the provider does not track the correct state for this property?

@oleksiidv
Copy link

@phillbaker @leolorenzoluis

Hi,

Has anyone found how to solve this issue?
I tried using a different provider "opensearch-project/opensearch". The same problem.
Maybe there is another option on how to import (add) OpenSearch alerts to terrafrom?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants