Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
OpenSearch 2.15
Describe the issue:
I have set up an opensearch domain/pipeline/dashboard in terraform and then also created an index pattern in terraform that i can set up queries/visualisations against. When i create visualisations against this manually in the opensearch dashboards console this works, however i have been trying to replicate this metric creation in terraform as i need to implement this across multiple accounts. here is the resource block to do this:
resource “opensearch_dashboard_object” “visualization” {
tenant_name = “tenant”
body = <<EOF
[
{
“_id”: “visualization:${var.account_alias}-daily-device-numbers”,
“_type”: “doc”,
“_source”: {
“type”: “visualization”,
“visualization”: {
“title”: “Daily device numbers”,
“visState”: “{"title":"daily device numbers","type":"metric","params":{"addTooltip":true},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric"}]}”,
“uiStateJSON”: “{}”,
“description”: “count the number of devices in certain categories”,
“version”: 1
}
}
}
]
EOF
}
Relevant Logs or Screenshots:
However when i try to view this in the visualization in the opensearch console i get the following error (the index pattern i created is the default index pattern so it should target this) - Failed to load the visualization, Trying to initialize aggs without index pattern