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

feat(new sink): Initial datadog_events sink #7678

Merged
merged 16 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ scopes:
- blackhole sink # Anything `blackhole` sink related
- clickhouse sink # Anything `clickhouse` sink related
- console sink # Anything `console` sink related
- datadog_events sink # Anything `datadog_events` sink related
- datadog_logs sink # Anything `datadog_logs` sink related
- datadog_metrics sink # Anything `datadog_metrics` sink related
- elasticsearch sink # Anything `elasticsearch` sink related
Expand Down
75 changes: 75 additions & 0 deletions docs/reference/components/sinks/datadog_events.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package metadata

components: sinks: datadog_events: {
title: "Datadog Events"

classes: sinks._datadog.classes

features: {
buffer: enabled: true
healthcheck: enabled: true
send: {
batch: {
enabled: false
common: false
timeout_secs: 0
}
compression: enabled: false
encoding: enabled: false
request: {
enabled: true
adaptive_concurrency: true
concurrency: 5
rate_limit_duration_secs: 1
rate_limit_num: 5
retry_initial_backoff_secs: 1
retry_max_duration_secs: 10
timeout_secs: 30
headers: false
}
tls: {
enabled: true
can_enable: true
can_verify_certificate: true
can_verify_hostname: true
enabled_default: true
}
to: {
service: services.datadog_events

interface: {
socket: {
api: {
title: "Datadog events API"
url: urls.datadog_events_endpoints
}
direction: "outgoing"
protocols: ["http"]
ssl: "required"
}
}
}
}
}

support: sinks._datadog.support

configuration: {
default_api_key: {
description: "Default Datadog [API key](https://docs.datadoghq.com/api/?lang=bash#authentication), if an event has a key set in its metadata it will prevail over the one set here."
required: true
warnings: []
type: string: {
examples: ["${DATADOG_API_KEY_ENV_VAR}", "ef8d5de700e7989468166c40fc8a0ccd"]
syntax: "literal"
}
}
endpoint: sinks._datadog.configuration.endpoint
site: sinks._datadog.configuration.site
}

input: {
logs: true
metrics: null
}
}
10 changes: 10 additions & 0 deletions docs/reference/services/datadog_events.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package metadata

services: datadog_events: {
name: "Datadog events"
thing: "a \(name) index"
url: urls.datadog_events
versions: null

description: services._datadog.description
}
2 changes: 2 additions & 0 deletions docs/reference/urls.cue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ urls: {
datadog_agent: "https://github.com/DataDog/datadog-agent"
datadog_distribution: "\(datadog_docs)/developers/metrics/types/?tab=distribution#definition"
datadog_docs: "https://docs.datadoghq.com"
datadog_events: "\(datadog_docs)/events/"
datadog_events_endpoints: "\(datadog_docs)/api/latest/events/#post-an-event"
datadog_logs: "\(datadog_docs)/logs/"
datadog_logs_endpoints: "\(datadog_docs)/logs/log_collection/?tab=http#datadog-logs-endpoints"
datadog_metrics: "\(datadog_docs)/metrics/"
Expand Down
6 changes: 6 additions & 0 deletions lib/vector-core/src/event/util/log/path_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ pub enum PathComponent {
Invalid,
}

impl<'a> From<&'a str> for PathComponent {
fn from(key: &'a str) -> Self {
Self::Key(key.to_string())
}
}
ktff marked this conversation as resolved.
Show resolved Hide resolved

/// Iterator over components of paths specified in form `a.b[0].c[2]`.
pub struct PathIter<'a> {
path: &'a str,
Expand Down
35 changes: 35 additions & 0 deletions src/internal_events/datadog_events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use super::InternalEvent;
use metrics::counter;

#[derive(Debug)]
pub struct DatadogEventsProcessed {
pub byte_size: usize,
}

impl InternalEvent for DatadogEventsProcessed {
fn emit_metrics(&self) {
counter!("processed_bytes_total", self.byte_size as u64);
}
}

#[derive(Debug)]
pub struct DatadogEventsFieldInvalid {
pub field: &'static str,
}

impl InternalEvent for DatadogEventsFieldInvalid {
fn emit_logs(&self) {
debug!(
message = "Required field is missing.",
field = %self.field,
internal_log_rate_secs = 10
);
ktff marked this conversation as resolved.
Show resolved Hide resolved
}

fn emit_metrics(&self) {
counter!(
"processing_errors_total", 1,
"error_type" => "field_missing",
"field" => self.field);
}
}
4 changes: 4 additions & 0 deletions src/internal_events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mod concat;
#[cfg(feature = "sinks-console")]
mod console;
#[cfg(feature = "sinks-datadog")]
mod datadog_events;
#[cfg(feature = "sinks-datadog")]
mod datadog_logs;
#[cfg(feature = "transforms-dedupe")]
mod dedupe;
Expand Down Expand Up @@ -151,6 +153,8 @@ pub use self::concat::*;
#[cfg(feature = "sinks-console")]
pub use self::console::*;
#[cfg(feature = "sinks-datadog")]
pub use self::datadog_events::*;
#[cfg(feature = "sinks-datadog")]
pub use self::datadog_logs::*;
#[cfg(feature = "transforms-dedupe")]
pub(crate) use self::dedupe::*;
Expand Down
Loading