1. Packages
  2. Opensearch Provider
  3. API Docs
  4. Monitor
opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project

opensearch.Monitor

Explore with Pulumi AI

Provides an OpenSearch monitor. Please refer to the OpenSearch monitor documentation for details.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as opensearch from "@pulumi/opensearch";

const moviesLastHour = new opensearch.Monitor("moviesLastHour", {body: `{
  "name": "test-monitor",
  "type": "monitor",
  "enabled": true,
  "schedule": {
    "period": {
      "interval": 1,
      "unit": "MINUTES"
    }
  },
  "inputs": [{
    "search": {
      "indices": ["movies"],
      "query": {
        "size": 0,
        "aggregations": {},
        "query": {
          "bool": {
            "adjust_pure_negative":true,
            "boost":1,
            "filter": [{
              "range": {
                "@timestamp": {
                  "boost":1,
                  "from":"||-1h",
                  "to":"",
                  "include_lower":true,
                  "include_upper":true,
                  "format": "epoch_millis"
                }
              }
            }]
          }
        }
      }
    }
  }],
  "triggers": [
    {
      "name" : "Errors",
      "severity" : "1",
      "condition" : {
        "script" : {
          "source" : "ctx.results[0].hits.total.value > 0",
          "lang" : "painless"
        }
      },
      "actions" : [
        {
          "name" : "Slack",
          "destination_id" : "${opensearch_channel_configuration.slack_on_call_channel.id}",
          "message_template" : {
            "source" : "bogus",
            "lang" : "mustache"
          },
          "throttle_enabled" : false,
          "subject_template" : {
            "source" : "Production Errors",
            "lang" : "mustache"
          }
        }
      ]
    }
  ]
}

`});
Copy
import pulumi
import pulumi_opensearch as opensearch

movies_last_hour = opensearch.Monitor("moviesLastHour", body=f"""{{
  "name": "test-monitor",
  "type": "monitor",
  "enabled": true,
  "schedule": {{
    "period": {{
      "interval": 1,
      "unit": "MINUTES"
    }}
  }},
  "inputs": [{{
    "search": {{
      "indices": ["movies"],
      "query": {{
        "size": 0,
        "aggregations": {{}},
        "query": {{
          "bool": {{
            "adjust_pure_negative":true,
            "boost":1,
            "filter": [{{
              "range": {{
                "@timestamp": {{
                  "boost":1,
                  "from":"||-1h",
                  "to":"",
                  "include_lower":true,
                  "include_upper":true,
                  "format": "epoch_millis"
                }}
              }}
            }}]
          }}
        }}
      }}
    }}
  }}],
  "triggers": [
    {{
      "name" : "Errors",
      "severity" : "1",
      "condition" : {{
        "script" : {{
          "source" : "ctx.results[0].hits.total.value > 0",
          "lang" : "painless"
        }}
      }},
      "actions" : [
        {{
          "name" : "Slack",
          "destination_id" : "{opensearch_channel_configuration["slack_on_call_channel"]["id"]}",
          "message_template" : {{
            "source" : "bogus",
            "lang" : "mustache"
          }},
          "throttle_enabled" : false,
          "subject_template" : {{
            "source" : "Production Errors",
            "lang" : "mustache"
          }}
        }}
      ]
    }}
  ]
}}

""")
Copy
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-terraform-provider/sdks/go/opensearch/v2/opensearch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := opensearch.NewMonitor(ctx, "moviesLastHour", &opensearch.MonitorArgs{
			Body: pulumi.Sprintf(`{
  "name": "test-monitor",
  "type": "monitor",
  "enabled": true,
  "schedule": {
    "period": {
      "interval": 1,
      "unit": "MINUTES"
    }
  },
  "inputs": [{
    "search": {
      "indices": ["movies"],
      "query": {
        "size": 0,
        "aggregations": {},
        "query": {
          "bool": {
            "adjust_pure_negative":true,
            "boost":1,
            "filter": [{
              "range": {
                "@timestamp": {
                  "boost":1,
                  "from":"||-1h",
                  "to":"",
                  "include_lower":true,
                  "include_upper":true,
                  "format": "epoch_millis"
                }
              }
            }]
          }
        }
      }
    }
  }],
  "triggers": [
    {
      "name" : "Errors",
      "severity" : "1",
      "condition" : {
        "script" : {
          "source" : "ctx.results[0].hits.total.value > 0",
          "lang" : "painless"
        }
      },
      "actions" : [
        {
          "name" : "Slack",
          "destination_id" : "%v",
          "message_template" : {
            "source" : "bogus",
            "lang" : "mustache"
          },
          "throttle_enabled" : false,
          "subject_template" : {
            "source" : "Production Errors",
            "lang" : "mustache"
          }
        }
      ]
    }
  ]
}

`, opensearch_channel_configuration.Slack_on_call_channel.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Opensearch = Pulumi.Opensearch;

return await Deployment.RunAsync(() => 
{
    var moviesLastHour = new Opensearch.Monitor("moviesLastHour", new()
    {
        Body = @$"{{
  ""name"": ""test-monitor"",
  ""type"": ""monitor"",
  ""enabled"": true,
  ""schedule"": {{
    ""period"": {{
      ""interval"": 1,
      ""unit"": ""MINUTES""
    }}
  }},
  ""inputs"": [{{
    ""search"": {{
      ""indices"": [""movies""],
      ""query"": {{
        ""size"": 0,
        ""aggregations"": {{}},
        ""query"": {{
          ""bool"": {{
            ""adjust_pure_negative"":true,
            ""boost"":1,
            ""filter"": [{{
              ""range"": {{
                ""@timestamp"": {{
                  ""boost"":1,
                  ""from"":""||-1h"",
                  ""to"":"""",
                  ""include_lower"":true,
                  ""include_upper"":true,
                  ""format"": ""epoch_millis""
                }}
              }}
            }}]
          }}
        }}
      }}
    }}
  }}],
  ""triggers"": [
    {{
      ""name"" : ""Errors"",
      ""severity"" : ""1"",
      ""condition"" : {{
        ""script"" : {{
          ""source"" : ""ctx.results[0].hits.total.value > 0"",
          ""lang"" : ""painless""
        }}
      }},
      ""actions"" : [
        {{
          ""name"" : ""Slack"",
          ""destination_id"" : ""{opensearch_channel_configuration.Slack_on_call_channel.Id}"",
          ""message_template"" : {{
            ""source"" : ""bogus"",
            ""lang"" : ""mustache""
          }},
          ""throttle_enabled"" : false,
          ""subject_template"" : {{
            ""source"" : ""Production Errors"",
            ""lang"" : ""mustache""
          }}
        }}
      ]
    }}
  ]
}}

",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.opensearch.Monitor;
import com.pulumi.opensearch.MonitorArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var moviesLastHour = new Monitor("moviesLastHour", MonitorArgs.builder()
            .body("""
{
  "name": "test-monitor",
  "type": "monitor",
  "enabled": true,
  "schedule": {
    "period": {
      "interval": 1,
      "unit": "MINUTES"
    }
  },
  "inputs": [{
    "search": {
      "indices": ["movies"],
      "query": {
        "size": 0,
        "aggregations": {},
        "query": {
          "bool": {
            "adjust_pure_negative":true,
            "boost":1,
            "filter": [{
              "range": {
                "@timestamp": {
                  "boost":1,
                  "from":"||-1h",
                  "to":"",
                  "include_lower":true,
                  "include_upper":true,
                  "format": "epoch_millis"
                }
              }
            }]
          }
        }
      }
    }
  }],
  "triggers": [
    {
      "name" : "Errors",
      "severity" : "1",
      "condition" : {
        "script" : {
          "source" : "ctx.results[0].hits.total.value > 0",
          "lang" : "painless"
        }
      },
      "actions" : [
        {
          "name" : "Slack",
          "destination_id" : "%s",
          "message_template" : {
            "source" : "bogus",
            "lang" : "mustache"
          },
          "throttle_enabled" : false,
          "subject_template" : {
            "source" : "Production Errors",
            "lang" : "mustache"
          }
        }
      ]
    }
  ]
}

", opensearch_channel_configuration.slack_on_call_channel().id()))
            .build());

    }
}
Copy
resources:
  moviesLastHour:
    type: opensearch:Monitor
    properties:
      body: |+
        {
          "name": "test-monitor",
          "type": "monitor",
          "enabled": true,
          "schedule": {
            "period": {
              "interval": 1,
              "unit": "MINUTES"
            }
          },
          "inputs": [{
            "search": {
              "indices": ["movies"],
              "query": {
                "size": 0,
                "aggregations": {},
                "query": {
                  "bool": {
                    "adjust_pure_negative":true,
                    "boost":1,
                    "filter": [{
                      "range": {
                        "@timestamp": {
                          "boost":1,
                          "from":"||-1h",
                          "to":"",
                          "include_lower":true,
                          "include_upper":true,
                          "format": "epoch_millis"
                        }
                      }
                    }]
                  }
                }
              }
            }
          }],
          "triggers": [
            {
              "name" : "Errors",
              "severity" : "1",
              "condition" : {
                "script" : {
                  "source" : "ctx.results[0].hits.total.value > 0",
                  "lang" : "painless"
                }
              },
              "actions" : [
                {
                  "name" : "Slack",
                  "destination_id" : "${opensearch_channel_configuration.slack_on_call_channel.id}",
                  "message_template" : {
                    "source" : "bogus",
                    "lang" : "mustache"
                  },
                  "throttle_enabled" : false,
                  "subject_template" : {
                    "source" : "Production Errors",
                    "lang" : "mustache"
                  }
                }
              ]
            }
          ]
        }        
Copy

Create Monitor Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Monitor(name: string, args: MonitorArgs, opts?: CustomResourceOptions);
@overload
def Monitor(resource_name: str,
            args: MonitorArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def Monitor(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            body: Optional[str] = None,
            monitor_id: Optional[str] = None)
func NewMonitor(ctx *Context, name string, args MonitorArgs, opts ...ResourceOption) (*Monitor, error)
public Monitor(string name, MonitorArgs args, CustomResourceOptions? opts = null)
public Monitor(String name, MonitorArgs args)
public Monitor(String name, MonitorArgs args, CustomResourceOptions options)
type: opensearch:Monitor
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. MonitorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. MonitorArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. MonitorArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. MonitorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. MonitorArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var monitorResource = new Opensearch.Monitor("monitorResource", new()
{
    Body = "string",
    MonitorId = "string",
});
Copy
example, err := opensearch.NewMonitor(ctx, "monitorResource", &opensearch.MonitorArgs{
	Body:      pulumi.String("string"),
	MonitorId: pulumi.String("string"),
})
Copy
var monitorResource = new Monitor("monitorResource", MonitorArgs.builder()
    .body("string")
    .monitorId("string")
    .build());
Copy
monitor_resource = opensearch.Monitor("monitorResource",
    body="string",
    monitor_id="string")
Copy
const monitorResource = new opensearch.Monitor("monitorResource", {
    body: "string",
    monitorId: "string",
});
Copy
type: opensearch:Monitor
properties:
    body: string
    monitorId: string
Copy

Monitor Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Monitor resource accepts the following input properties:

Body This property is required. string
The monitor document
MonitorId string
The ID of this resource.
Body This property is required. string
The monitor document
MonitorId string
The ID of this resource.
body This property is required. String
The monitor document
monitorId String
The ID of this resource.
body This property is required. string
The monitor document
monitorId string
The ID of this resource.
body This property is required. str
The monitor document
monitor_id str
The ID of this resource.
body This property is required. String
The monitor document
monitorId String
The ID of this resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the Monitor resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Monitor Resource

Get an existing Monitor resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: MonitorState, opts?: CustomResourceOptions): Monitor
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        body: Optional[str] = None,
        monitor_id: Optional[str] = None) -> Monitor
func GetMonitor(ctx *Context, name string, id IDInput, state *MonitorState, opts ...ResourceOption) (*Monitor, error)
public static Monitor Get(string name, Input<string> id, MonitorState? state, CustomResourceOptions? opts = null)
public static Monitor get(String name, Output<String> id, MonitorState state, CustomResourceOptions options)
resources:  _:    type: opensearch:Monitor    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Body string
The monitor document
MonitorId string
The ID of this resource.
Body string
The monitor document
MonitorId string
The ID of this resource.
body String
The monitor document
monitorId String
The ID of this resource.
body string
The monitor document
monitorId string
The ID of this resource.
body str
The monitor document
monitor_id str
The ID of this resource.
body String
The monitor document
monitorId String
The ID of this resource.

Import

$ pulumi import opensearch:index/monitor:Monitor alert lgOZb3UB96pyyRQv0ppQ
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
opensearch opensearch-project/terraform-provider-opensearch
License
Notes
This Pulumi package is based on the opensearch Terraform Provider.