New Relic

Pulumi Official
Package maintained by Pulumi
v4.19.0 published on Wednesday, Jul 20, 2022 by Pulumi

getMonitor

Use this data source to get information about a specific synthetics monitor in New Relic that already exists. This can be used to set up a Synthetics alert condition.

Example Usage

using Pulumi;
using NewRelic = Pulumi.NewRelic;

class MyStack : Stack
{
    public MyStack()
    {
        var bar = Output.Create(NewRelic.Synthetics.GetMonitor.InvokeAsync(new NewRelic.Synthetics.GetMonitorArgs
        {
            Name = "bar",
        }));
        var baz = new NewRelic.Synthetics.AlertCondition("baz", new NewRelic.Synthetics.AlertConditionArgs
        {
            PolicyId = newrelic_alert_policy.Foo.Id,
            MonitorId = bar.Apply(bar => bar.Id),
            RunbookUrl = "https://www.example.com",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-newrelic/sdk/v4/go/newrelic/synthetics"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		bar, err := synthetics.LookupMonitor(ctx, &synthetics.LookupMonitorArgs{
			Name: "bar",
		}, nil)
		if err != nil {
			return err
		}
		_, err = synthetics.NewAlertCondition(ctx, "baz", &synthetics.AlertConditionArgs{
			PolicyId:   pulumi.Any(newrelic_alert_policy.Foo.Id),
			MonitorId:  pulumi.String(bar.Id),
			RunbookUrl: pulumi.String("https://www.example.com"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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

    public static void stack(Context ctx) {
        final var bar = Output.of(SyntheticsFunctions.getMonitor(GetMonitorArgs.builder()
            .name("bar")
            .build()));

        var baz = new AlertCondition("baz", AlertConditionArgs.builder()        
            .policyId(newrelic_alert_policy.getFoo().getId())
            .monitorId(bar.apply(getMonitorResult -> getMonitorResult.getId()))
            .runbookUrl("https://www.example.com")
            .build());

        }
}
import pulumi
import pulumi_newrelic as newrelic

bar = newrelic.synthetics.get_monitor(name="bar")
baz = newrelic.synthetics.AlertCondition("baz",
    policy_id=newrelic_alert_policy["foo"]["id"],
    monitor_id=bar.id,
    runbook_url="https://www.example.com")
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";

const bar = newrelic.synthetics.getMonitor({
    name: "bar",
});
const baz = new newrelic.synthetics.AlertCondition("baz", {
    policyId: newrelic_alert_policy.foo.id,
    monitorId: bar.then(bar => bar.id),
    runbookUrl: "https://www.example.com",
});
resources:
  baz:
    type: newrelic:synthetics:AlertCondition
    properties:
      policyId: ${newrelic_alert_policy.foo.id}
      monitorId: ${bar.id}
      runbookUrl: https://www.example.com
variables:
  bar:
    Fn::Invoke:
      Function: newrelic:synthetics:getMonitor
      Arguments:
        name: bar

Using getMonitor

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getMonitor(args: GetMonitorArgs, opts?: InvokeOptions): Promise<GetMonitorResult>
function getMonitorOutput(args: GetMonitorOutputArgs, opts?: InvokeOptions): Output<GetMonitorResult>
def get_monitor(name: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetMonitorResult
def get_monitor_output(name: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetMonitorResult]
func LookupMonitor(ctx *Context, args *LookupMonitorArgs, opts ...InvokeOption) (*LookupMonitorResult, error)
func LookupMonitorOutput(ctx *Context, args *LookupMonitorOutputArgs, opts ...InvokeOption) LookupMonitorResultOutput

> Note: This function is named LookupMonitor in the Go SDK.

public static class GetMonitor 
{
    public static Task<GetMonitorResult> InvokeAsync(GetMonitorArgs args, InvokeOptions? opts = null)
    public static Output<GetMonitorResult> Invoke(GetMonitorInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetMonitorResult> getMonitor(GetMonitorArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: newrelic:synthetics/getMonitor:getMonitor
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Name string

The name of the synthetics monitor in New Relic.

Name string

The name of the synthetics monitor in New Relic.

name String

The name of the synthetics monitor in New Relic.

name string

The name of the synthetics monitor in New Relic.

name str

The name of the synthetics monitor in New Relic.

name String

The name of the synthetics monitor in New Relic.

getMonitor Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

MonitorId string

The ID of the synthetics monitor.

Name string
Id string

The provider-assigned unique ID for this managed resource.

MonitorId string

The ID of the synthetics monitor.

Name string
id String

The provider-assigned unique ID for this managed resource.

monitorId String

The ID of the synthetics monitor.

name String
id string

The provider-assigned unique ID for this managed resource.

monitorId string

The ID of the synthetics monitor.

name string
id str

The provider-assigned unique ID for this managed resource.

monitor_id str

The ID of the synthetics monitor.

name str
id String

The provider-assigned unique ID for this managed resource.

monitorId String

The ID of the synthetics monitor.

name String

Package Details

Repository
https://github.com/pulumi/pulumi-newrelic
License
Apache-2.0
Notes

This Pulumi package is based on the newrelic Terraform Provider.