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

[Datadog] Add support for Logs Public config API #312

Merged
merged 12 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from 10 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
182 changes: 182 additions & 0 deletions datadog/import_datadog_logs_pipeline_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
package datadog

import (
"github.com/hashicorp/terraform/helper/resource"
"testing"
)

const pipelineConfigForImport = `
resource "datadog_logs_pipeline" "test_import" {
name = "imported pipeline"
is_enabled = false
filter {
query = "source:kafka"
}
processor {
arithmetic_processor {
name = "test arithmetic processor"
expression = "(time1 - time2)*1000"
target = "my_arithmetic"
is_replace_missing = true
}
}
processor {
attribute_remapper {
name = "test attribute remapper"
is_enabled = true
sources = ["db.instance"]
source_type = "tag"
target = "db"
target_type = "tag"
preserve_source = true
override_on_conflict = false
}
}
processor {
category_processor {
name = "test category processor"
target = "redis.severity"
category {
name = "debug"
filter {
query = "@severity: \".\""
}
}
category {
name = "verbose"
filter {
query = "@severity: \"-\""
}
}
}
}
processor {
date_remapper {
name = "test date remapper"
is_enabled = true
sources = ["date"]
}
}
processor {
date_remapper {
name = "2nd date remapper"
is_enabled = true
sources = ["other"]
}
}
processor {
message_remapper {
name = "test message remapper"
is_enabled = false
sources = ["message"]
}
}
processor {
service_remapper {
name = "test service remapper"
sources = ["service"]
}
}
processor {
status_remapper {
name = "test status remapper"
sources = ["status", "extra"]
}
}
processor {
trace_id_remapper {
name = "test trace id remapper"
sources = ["dd.trace_id"]
}
}
processor {
pipeline {
name = "nested pipeline"
filter {
query = "source:redis"
}
processor {
grok_parser {
name = "test grok parser"
source = "message"
grok {
support_rules = ""
match_rules = "Rule %%{word:my_word2} %%{number:my_float2}"
}
}
}
processor {
url_parser {
name = "test url parser"
sources = ["url", "extra"]
target = "http_url"
normalize_ending_slashes = true
}
}
}
}
processor {
user_agent_parser {
name = "test user agent parser"
sources = ["user", "agent"]
target = "http_agent"
is_encoded = false
}
}
}
`

const pipelineorderConfigForImport = `
resource "datadog_logs_pipeline_order" "pipelines" {
name = "pipelines"
pipelines = [
"TOYNsNfjTD6zTXVg8_ej1g",
tt810 marked this conversation as resolved.
Show resolved Hide resolved
"VxXfWxegScyjG8mMJwnFIA",
"GGVTp-5PT_O9Xhmsxnsu_w",
"VgZXJneKR2qh2WcfAQi6fA"
]
}
`

func TestAccLogsPipeline_importBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPipelineDestroy,
Steps: []resource.TestStep{
{
Config: pipelineConfigForImport,
Check: resource.ComposeTestCheckFunc(
testAccCheckPipelineExists("datadog_logs_pipeline.test_import"),
resource.TestCheckResourceAttr(
"datadog_logs_pipeline.test_import", "name", "imported pipeline"),
),
},
{
ResourceName: "datadog_logs_pipeline.test_import",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccLogsPipelineOrder_importBasic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: pipelineorderConfigForImport,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"datadog_logs_pipelineorder.pipelines", "name", "pipelines"),
),
},
{
ResourceName: "datadog_logs_pipelineorder.pipelines",
ImportState: true,
},
},
})
}
4 changes: 3 additions & 1 deletion datadog/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
datadog "github.com/zorkian/go-datadog-api"
"github.com/zorkian/go-datadog-api"
)

func Provider() terraform.ResourceProvider {
Expand Down Expand Up @@ -46,6 +46,8 @@ func Provider() terraform.ResourceProvider {
"datadog_synthetics_test": resourceDatadogSyntheticsTest(),
"datadog_timeboard": resourceDatadogTimeboard(),
"datadog_user": resourceDatadogUser(),
"datadog_logs_pipeline": resourceDatadogLogsPipeline(),
"datadog_logs_pipeline_order": resourceDatadogLogsPipelineOrder(),
},

ConfigureFunc: providerConfigure,
Expand Down
Loading