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

feat: dashbaord obj submodule #55

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions examples/dashboard/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module "tenant" {
source = "../../modules/dashboard/tenant"

name = "test-tenant"
}

module "index_pattern" {
source = "../../modules/dashboard/index-pattern"

tenant_name = module.tenant.name
pattern = "test-*"
time_field_name = var.time_field_name
}

module "dashboard" {
source = "../../modules/dashboard/object"

tenant_name = module.tenant.name

body = <<EOF
[
{
"_id": "visualization:response-time-percentile",
"_type": "doc",
"_source": {
"type": "visualization",
"visualization": {
"title": "Total response time percentiles",
"visState": "{\"title\":\"Total response time percentiles\",\"type\":\"line\",\"params\":{\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"showCircles\":true,\"interpolate\":\"linear\",\"scale\":\"linear\",\"drawLinesBetweenPoints\":true,\"radiusRatio\":9,\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"percentiles\",\"schema\":\"metric\",\"params\":{\"field\":\"app.total_time\",\"percents\":[50,90,95]}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"system.syslog.program\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"_term\"}}],\"listeners\":{}}",
"uiStateJSON": "{}",
"description": "",
"version": 1
}
}
}
]
EOF
}
2 changes: 2 additions & 0 deletions examples/dashboard/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
provider "opensearch" {
}
17 changes: 17 additions & 0 deletions examples/dashboard/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "pattern" {
description = "The index pattern"
type = string
default = "test-pattern-*"
}

variable "pattern_id" {
description = "The ID of index pattern"
type = string
default = "test"
}

variable "time_field_name" {
description = "Field name which has the timestamp"
type = string
default = "timestamp"
}
10 changes: 10 additions & 0 deletions examples/dashboard/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.4"

required_providers {
opensearch = {
source = "opensearch-project/opensearch"
version = "~> 2.3.0"
}
}
}
4 changes: 4 additions & 0 deletions modules/dashboard/object/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "opensearch_dashboard_object" "this" {
tenant_name = var.tenant_name
body = jsonencode(var.body)
}
4 changes: 4 additions & 0 deletions modules/dashboard/object/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "id" {
description = "The ID of the object"
value = opensearch_dashboard_object.this.id
}
10 changes: 10 additions & 0 deletions modules/dashboard/object/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "tenant_name" {
description = "The name of the tenant to which dashboard data associates. Empty string defaults to global tenant"
type = string
default = ""
}

variable "body" {
description = "The dashboard document in JSON or HCL"
type = any
}
10 changes: 10 additions & 0 deletions modules/dashboard/object/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.4"

required_providers {
opensearch = {
source = "opensearch-project/opensearch"
version = ">= 2.0"
}
}
}
5 changes: 5 additions & 0 deletions modules/dashboard/tenant/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ output "id" {
description = "The ID of the dashboard tenant"
value = opensearch_dashboard_tenant.this.id
}

output "name" {
description = "The name of the dashboard tenant"
value = opensearch_dashboard_tenant.this.tenant_name
}
Loading