fake-intake

command module
v0.0.0-...-4cd0189 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

Datadog Fake Intake

Exposes a catch-all API for Datadog Agent POST requests.

Requirements

How to run

Locally
  1. cd to fake-intake root folder
cd ~/dd/datadog-agent/test/fake-intake
  1. Build the fake-intake app
go build
  1. Run the fake-intake
./fake-intake
  1. Configure Datadog Agent to use fake intake
# datadog.yaml
DD_DD_URL: "http://localhost:8080"
Docker
  1. cd to fake-intake root folder
cd ~/dd/datadog-agent/test/fake-intake
  1. Start the docker container
docker compose up
  1. Configure Datadog Agent to use fake intake
# datadog.yaml
DD_DD_URL: "http://localhost:8080"

How to build

🐳 Docker, locally
  1. Ensure you are using buildx desktop-linux driver
docker buildx create --use desktop-linux
  1. Build a new multi-arch image using buildx. This will allow the container to run on both MacOS M1 (arm64) and Linux (amd64).
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag <repo_name>/fake-intake:<tag> .

API

Get payloads

Returns all payloads submitted to a POST endpoint as byte arrays, encoded in base64.

Response
{
  "payloads": [][]byte
}

Example:

{
  "payloads": [
    "dG90b3JvfDI1fG93bmVyOmtpa2k=" // use `b64.StdEncoding.DecodeString(str)` in golang or base64.b64decode(str) in python
  ]
}
curl
curl ${SERVICE_IP}/fake/payloads/{post_endpoint_path}

Example:

curl ${SERVICE_IP}/fake/payloads/api/V2/series
Juniper Notebook

Play with fake-intake in a Juniper Notebook

# POST payloads
import base64
import requests
import json

data = "totoro|25|owner:kiki"
response = requests.post("http://localhost:8080/api/v2/series", data)

json_content = response.content.decode('utf8')

print(json_content)

# GET payloads
import base64
import requests
import json

response = requests.get("http://localhost:8080/fake/payloads/api/v2/series")

json_content = response.content.decode('utf8')

data = json.loads(json_content)

print(data)

print("==== Payloads ====")
for payload in data["payloads"]:
    print(base64.b64decode(payload))

Development in VSCode

This is a sub-module within datadog-agent. VSCode will complain about the multiple go.mod files. While waiting for a full repo migration to go workspaces, create a go workspace file and add test/fake-intake to workspaces

go work init
go work use . ./test/fake-intake

Note go.work file is currently ignored in datadog-agent

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL