| layout | newrelic |
|---|---|
| page_title | New Relic: newrelic_workload |
| sidebar_current | docs-newrelic-resource-workload |
| description | Create and manage a New Relic One workload. |
Use this resource to create, update, and delete a New Relic One workload.
A New Relic User API key is required to provision this resource. Set the api_key
attribute in the provider block or the NEW_RELIC_API_KEY environment
variable with your User API key.
Include entities with a certain string on the name.
resource "newrelic_workload" "foo" {
name = "Example workload"
account_id = 12345678
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
entity_search_query {
query = "name like '%Example application%'"
}
scope_account_ids = [12345678]
}Include entities with a set of tags.
resource "newrelic_workload" "foo" {
name = "Example workload with tags"
account_id = 12345678
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
entity_search_query {
query = "tags.accountId = '12345678' AND tags.environment='production' AND tags.language='java'"
}
scope_account_ids = [12345678]
}Include entities with a set of tags.
resource "newrelic_workload" "foo" {
name = "Example workload with tags"
account_id = 12345678
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
entity_search_query {
query = "tags.accountId = '12345678' AND tags.environment='production' AND tags.language='java'"
}
scope_account_ids = [12345678]
}Include automatic status
-> The global status of your workload is a quick indicator of the workload health. You can configure it to be calculated automatically, and you can also set an alert and get a notification whenever the workload stops being operational. Alternatively, you can communicate a certain status of the workload by setting up a static value and a description. See our docs
resource "newrelic_workload" "foo" {
name = "Example workload"
account_id = 12345678
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
entity_search_query {
query = "name like '%Example application%'"
}
scope_account_ids = [12345678]
description = "Description"
status_config_automatic {
enabled = true
remaining_entities_rule {
remaining_entities_rule_rollup {
strategy = "BEST_STATUS_WINS"
threshold_type = "FIXED"
threshold_value = 100
group_by = "ENTITY_TYPE"
}
}
rule {
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
nrql_query {
query = "name like '%Example application2%'"
}
rollup {
strategy = "BEST_STATUS_WINS"
threshold_type = "FIXED"
threshold_value = 100
}
}
}
}Include static status
-> You can use this during maintenance tasks or any other time you want to provide a fixed status for your workload. This overrides all automatic rules. See our docs
resource "newrelic_workload" "foo" {
name = "Example workload"
account_id = 12345678
entity_guids = ["MjUyMDUyOHxBUE18QVBQTElDQVRJT058MjE1MDM3Nzk1"]
entity_search_query {
query = "name like '%Example application%'"
}
scope_account_ids = [12345678]
description = "Description"
status_config_static {
description = "test"
enabled = true
status = "OPERATIONAL"
summary = "summary of the status"
}
}The following arguments are supported:
name- (Required) The workload's name.account_id- (Required) The New Relic account ID where you want to create the workload.entity_guids- (Optional) A list of entity GUIDs manually assigned to this workload. At least one of eitherentity_guidsorentity_search_queryis required.entity_search_query- (Optional) A list of search queries that define a dynamic workload. At least one of eitherentity_guidsorentity_search_queryis required. See Nested entity_search_query blocks below for details.scope_account_ids- (Optional) A list of account IDs that will be used to get entities from.description- (Optional) Relevant information about the workload.status_config_automatic- (Optional) An input object used to represent an automatic status configuration.See Nested status_config_automatic blocks below for details.status_config_static- (Optional) A list of static status configurations. You can only configure one static status for a workload.See Nested status_config_static blocks below for details.
All nested entity_search_query blocks support the following common arguments:
query- (Required) A valid entity search query; empty, and null values are considered invalid.
enabled- (Required) Whether the automatic status configuration is enabled or not.remaining_entities_rule- (Optional) An additional meta-rule that can consider all entities that haven't been evaluated by any other rule. See Nested remaining_entities_rule blocks below for details.rule- (Optional) The input object used to represent a rollup strategy. See Nested rule blocks below for details.
description- (Optional) A description that provides additional details about the status of the workload.enabled- (Required) Whether the static status configuration is enabled or not.status- (Required) The status of the workload.summary- (Optional) A short description of the status of the workload.
remaining_entities_rule_rollup- (Required) The input object used to represent a rollup strategy. See Nested remaining_entities_rule_rollup blocks below for details.
All nested rule blocks support the following common arguments:
entity_guids- (Optional) A list of entity GUIDs composing the rule. At least one ofentity_guidsornrql_querymust be defined.nrql_query- (Optional) A list of entity search queries used to retrieve the entities that compose the rule. See Nested nrql_query blocks below for details. At least one ofentity_guidsornrql_querymust be defined.rollup- (Required) The input object used to represent a rollup strategy. See Nested rollup blocks below for details.
group_by- (Required) The grouping to be applied to the remaining entities.strategy- (Required) The rollup strategy that is applied to a group of entities.threshold_type- (Optional) Type of threshold defined for the rule. This is an optional field that only applies when strategy is WORST_STATUS_WINS. Use a threshold to roll up the worst status only after a certain amount of entities are not operational.threshold_value- (Optional) Threshold value defined for the rule. This optional field is used in combination with thresholdType. If the threshold type is null, the threshold value will be ignored.
All nested nrql_query blocks support the following common arguments:
query- The entity search query that is used to perform the search of a group of entities.
strategy- (Required) The rollup strategy that is applied to a group of entities.threshold_type- (Optional) Type of threshold defined for the rule. This is an optional field that only applies when strategy is WORST_STATUS_WINS. Use a threshold to roll up the worst status only after a certain amount of entities are not operational.threshold_value- (Optional) Threshold value defined for the rule. This optional field is used in combination with thresholdType. If the threshold type is null, the threshold value will be ignored.
The following attributes are exported:
guid- The unique entity identifier of the workload in New Relic.workload_id- The unique entity identifier of the workload.permalink- The URL of the workload.composite_entity_search_query- The composite query used to compose a dynamic workload.
New Relic workloads can be imported using a concatenated string of the format
<account_id>:<workload_id>:<guid>, e.g.
$ terraform import newrelic_workload.foo 12345678:1456:MjUyMDUyOHxBUE18QVBRTElDQVRJT058MjE1MDM3Nzk1~> NOTE: The value of <workload_id> can be derived from the base64 decoded value of <guid> - e.g. echo <guid> | base64 -d | cut -f 4 -d '|'