Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions aws/logs_monitoring_go/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"log/slog"
)

var ForwarderVersion = "dev"
var ForwarderVersion = "6.0"

type Config struct {
APIKey string
Expand Down Expand Up @@ -61,7 +61,7 @@ func loadConfig() *Config {
site := envOrDefault("DD_SITE", "datadoghq.com")
return &Config{
Site: site,
IntakeURL: envOrDefault("DD_URL", "https://http-intake.logs."+site),
IntakeURL: envOrDefault("DD_URL", "https://http-intake.logs."+site+"/api/v2/logs"),
APIURL: envOrDefault("DD_API_URL", "https://api."+site),
LogLevel: envOrDefault("DD_LOG_LEVEL", "INFO"),
UseFIPS: envOrDefaultBool("DD_USE_FIPS", false),
Expand Down
14 changes: 7 additions & 7 deletions aws/logs_monitoring_go/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestLoadConfig(t *testing.T) {
"default": {
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
UseFIPS: false,
Expand All @@ -30,7 +30,7 @@ func TestLoadConfig(t *testing.T) {
env: map[string]string{"DD_SITE": "datadoghq.eu"},
want: Config{
Site: "datadoghq.eu",
IntakeURL: "https://http-intake.logs.datadoghq.eu",
IntakeURL: "https://http-intake.logs.datadoghq.eu/api/v2/logs",
APIURL: "https://api.datadoghq.eu",
LogLevel: "INFO",
},
Expand All @@ -55,7 +55,7 @@ func TestLoadConfig(t *testing.T) {
},
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
Source: "custom-source",
Expand All @@ -67,7 +67,7 @@ func TestLoadConfig(t *testing.T) {
env: map[string]string{"REDACT_IP": "true"},
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
Scrubbing: ScrubbingConfig{ScrubIP: true},
Expand All @@ -80,7 +80,7 @@ func TestLoadConfig(t *testing.T) {
},
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
Scrubbing: ScrubbingConfig{CustomRule: `\d+`, CustomReplacement: "X"},
Expand All @@ -90,7 +90,7 @@ func TestLoadConfig(t *testing.T) {
env: map[string]string{"INCLUDE_AT_MATCH": `error|warn`},
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
Filtering: FilteringConfig{IncludePattern: `error|warn`},
Expand All @@ -100,7 +100,7 @@ func TestLoadConfig(t *testing.T) {
env: map[string]string{"EXCLUDE_AT_MATCH": `DEBUG`},
want: Config{
Site: "datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com",
IntakeURL: "https://http-intake.logs.datadoghq.com/api/v2/logs",
APIURL: "https://api.datadoghq.com",
LogLevel: "INFO",
Filtering: FilteringConfig{ExcludePattern: `DEBUG`},
Expand Down
17 changes: 9 additions & 8 deletions aws/logs_monitoring_go/internal/model/cloudwatchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
package model

type CloudwatchLogEntry struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Message string `json:"message"`
Source string `json:"ddsource"`
Service string `json:"service"`
Host string `json:"hostname"`
Tags Tags `json:"ddtags"`
AWS CloudwatchMetadata `json:"aws"`
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Message string `json:"message"`
Source string `json:"ddsource"`
SourceCategory string `json:"ddsourcecategory"`
Service string `json:"service"`
Host string `json:"hostname"`
Tags Tags `json:"ddtags"`
AWS CloudwatchMetadata `json:"aws"`
}

type CloudwatchMetadata struct {
Expand Down
19 changes: 11 additions & 8 deletions aws/logs_monitoring_go/internal/parsing/cloudwatchlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/aws/aws-lambda-go/lambdacontext"
)

const sourceCategory = "aws"

func HandleCloudwatchLogs(ctx context.Context, event json.RawMessage, cfg *config.Config, out chan<- model.CloudwatchLogEntry) error {
logEntries, err := parseCloudwatchLogs(ctx, event, cfg)
if err != nil {
Expand Down Expand Up @@ -67,14 +69,15 @@ func parseCloudwatchLogs(ctx context.Context, event json.RawMessage, cfg *config
ddtags = append(ddtags, "service:"+entryService)

entry := model.CloudwatchLogEntry{
ID: le.ID,
Timestamp: le.Timestamp,
Message: message,
Source: source,
Service: entryService,
Host: host,
Tags: append(ddtags, tags...),
AWS: metadata,
ID: le.ID,
Timestamp: le.Timestamp,
Message: message,
Source: source,
SourceCategory: sourceCategory,
Service: entryService,
Host: host,
Tags: append(ddtags, tags...),
AWS: metadata,
}
entries = append(entries, entry)
}
Expand Down
Loading