Example Usage
Create A New Relic One Dashboard From A JSON File
import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";
import * as std from "@pulumi/std";
const foo = new newrelic.OneDashboardJson("foo", {json: std.file({
input: "dashboard.json",
}).then(invoke => invoke.result)});
import pulumi
import pulumi_newrelic as newrelic
import pulumi_std as std
foo = newrelic.OneDashboardJson("foo", json=std.file(input="dashboard.json").result)
package main
import (
"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
invokeFile, err := std.File(ctx, &std.FileArgs{
Input: "dashboard.json",
}, nil)
if err != nil {
return err
}
_, err = newrelic.NewOneDashboardJson(ctx, "foo", &newrelic.OneDashboardJsonArgs{
Json: pulumi.String(invokeFile.Result),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var foo = new NewRelic.OneDashboardJson("foo", new()
{
Json = Std.File.Invoke(new()
{
Input = "dashboard.json",
}).Apply(invoke => invoke.Result),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.OneDashboardJson;
import com.pulumi.newrelic.OneDashboardJsonArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FileArgs;
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 foo = new OneDashboardJson("foo", OneDashboardJsonArgs.builder()
.json(StdFunctions.file(FileArgs.builder()
.input("dashboard.json")
.build()).result())
.build());
}
}
resources:
foo:
type: newrelic:OneDashboardJson
properties:
json:
fn::invoke:
function: std:file
arguments:
input: dashboard.json
return: result
Additional Examples
Setting Thresholds
The following example demonstrates setting thresholds on a billboard widget.
dashboard.json
{
"name" : "Sample",
"permissions" : "PUBLIC_READ_WRITE",
"pages" : [
{
"name" : "Sample Page",
"description" : "A guide to the metrics of daily transactions on the website.",
"widgets" : [
{
"title" : "Transaction Failure Tracker",
"layout" : {
"column" : 1,
"row" : 1,
"width" : 3,
"height" : 5
},
"visualization" : {
"id" : "viz.billboard"
},
"rawConfiguration" : {
"nrqlQueries" : [
{
"accountIds" : [
account_id
],
"query" : "SELECT count(*) from Transaction where httpResponseCode!=200 since 1 hour ago"
}
],
"thresholds" : [
{
"alertSeverity" : "WARNING",
"value" : 15
},
{
"alertSeverity" : "CRITICAL",
"value" : 40
}
]
}
}
]
}
]
}
More Complex Examples
The following examples show more intricate use cases of creating dashboards from JSON files, using this resource.
- This example illustrates the use of a variable list of items to create a dashboard, that may be used iteratively to populate queries and other arguments of widgets, using Terraform template files.
- This example elaborates on the use of an apt Terraform configuration with additional dependencies, to instrument the use of values obtained from a GraphQL API response iteratively to configure widgets in the dashboard for each item in the response, using the Terraform
jsondecodefunction.
More of such examples may be found in ths GitHub repository.
Create OneDashboardJson Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new OneDashboardJson(name: string, args: OneDashboardJsonArgs, opts?: CustomResourceOptions);@overload
def OneDashboardJson(resource_name: str,
args: OneDashboardJsonArgs,
opts: Optional[ResourceOptions] = None)
@overload
def OneDashboardJson(resource_name: str,
opts: Optional[ResourceOptions] = None,
json: Optional[str] = None,
account_id: Optional[str] = None)func NewOneDashboardJson(ctx *Context, name string, args OneDashboardJsonArgs, opts ...ResourceOption) (*OneDashboardJson, error)public OneDashboardJson(string name, OneDashboardJsonArgs args, CustomResourceOptions? opts = null)
public OneDashboardJson(String name, OneDashboardJsonArgs args)
public OneDashboardJson(String name, OneDashboardJsonArgs args, CustomResourceOptions options)
type: newrelic:OneDashboardJson
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args OneDashboardJsonArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args OneDashboardJsonArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args OneDashboardJsonArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args OneDashboardJsonArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args OneDashboardJsonArgs
- 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 oneDashboardJsonResource = new NewRelic.OneDashboardJson("oneDashboardJsonResource", new()
{
Json = "string",
AccountId = "string",
});
example, err := newrelic.NewOneDashboardJson(ctx, "oneDashboardJsonResource", &newrelic.OneDashboardJsonArgs{
Json: pulumi.String("string"),
AccountId: pulumi.String("string"),
})
var oneDashboardJsonResource = new OneDashboardJson("oneDashboardJsonResource", OneDashboardJsonArgs.builder()
.json("string")
.accountId("string")
.build());
one_dashboard_json_resource = newrelic.OneDashboardJson("oneDashboardJsonResource",
json="string",
account_id="string")
const oneDashboardJsonResource = new newrelic.OneDashboardJson("oneDashboardJsonResource", {
json: "string",
accountId: "string",
});
type: newrelic:OneDashboardJson
properties:
accountId: string
json: string
OneDashboardJson 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 OneDashboardJson resource accepts the following input properties:
- Json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- Account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- Json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- Account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- json String
- The JSON export of a dashboard. The JSON can be exported from the UI
- account
Id String - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- json str
- The JSON export of a dashboard. The JSON can be exported from the UI
- account_
id str - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- json String
- The JSON export of a dashboard. The JSON can be exported from the UI
- account
Id String - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
Outputs
All input properties are implicitly available as output properties. Additionally, the OneDashboardJson resource produces the following output properties:
- guid str
- The unique entity identifier of the dashboard in New Relic.
- id str
- The provider-assigned unique ID for this managed resource.
- permalink str
- The URL for viewing the dashboard.
- updated_
at str - The date and time when the dashboard was last updated.
Look up Existing OneDashboardJson Resource
Get an existing OneDashboardJson 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?: OneDashboardJsonState, opts?: CustomResourceOptions): OneDashboardJson@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
account_id: Optional[str] = None,
guid: Optional[str] = None,
json: Optional[str] = None,
permalink: Optional[str] = None,
updated_at: Optional[str] = None) -> OneDashboardJsonfunc GetOneDashboardJson(ctx *Context, name string, id IDInput, state *OneDashboardJsonState, opts ...ResourceOption) (*OneDashboardJson, error)public static OneDashboardJson Get(string name, Input<string> id, OneDashboardJsonState? state, CustomResourceOptions? opts = null)public static OneDashboardJson get(String name, Output<String> id, OneDashboardJsonState state, CustomResourceOptions options)resources: _: type: newrelic:OneDashboardJson get: id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- Guid string
- The unique entity identifier of the dashboard in New Relic.
- Json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- Permalink string
- The URL for viewing the dashboard.
- Updated
At string - The date and time when the dashboard was last updated.
- Account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- Guid string
- The unique entity identifier of the dashboard in New Relic.
- Json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- Permalink string
- The URL for viewing the dashboard.
- Updated
At string - The date and time when the dashboard was last updated.
- account
Id String - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- guid String
- The unique entity identifier of the dashboard in New Relic.
- json String
- The JSON export of a dashboard. The JSON can be exported from the UI
- permalink String
- The URL for viewing the dashboard.
- updated
At String - The date and time when the dashboard was last updated.
- account
Id string - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- guid string
- The unique entity identifier of the dashboard in New Relic.
- json string
- The JSON export of a dashboard. The JSON can be exported from the UI
- permalink string
- The URL for viewing the dashboard.
- updated
At string - The date and time when the dashboard was last updated.
- account_
id str - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- guid str
- The unique entity identifier of the dashboard in New Relic.
- json str
- The JSON export of a dashboard. The JSON can be exported from the UI
- permalink str
- The URL for viewing the dashboard.
- updated_
at str - The date and time when the dashboard was last updated.
- account
Id String - Determines the New Relic account where the dashboard will be created. Defaults to the account associated with the API key used.
- guid String
- The unique entity identifier of the dashboard in New Relic.
- json String
- The JSON export of a dashboard. The JSON can be exported from the UI
- permalink String
- The URL for viewing the dashboard.
- updated
At String - The date and time when the dashboard was last updated.
Import
New Relic dashboards can be imported using their GUID, e.g.
$ terraform import newrelic_one_dashboard_json.my_dashboard <dashboard GUID>
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- New Relic pulumi/pulumi-newrelic
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
newrelicTerraform Provider.
