Logtail Provider
Manage Logtail log management resources with Pulumi
The Logtail provider enables you to manage log sources, metrics, and analytics resources in Logtail using Pulumi. This provider is dynamically bridged from the Terraform Logtail Provider.
Installation
Install the Logtail provider package using your preferred package manager:
bun add pulumi-logtailpnpm add pulumi-logtailyarn add pulumi-logtailnpm install pulumi-logtailConfiguration
Getting API Token
- Log in to Logtail at logs.betterstack.com
- Navigate to Settings → API Tokens
- Create a new API token
- Copy the token value
Provider Setup
pulumi config set logtail:apiToken YOUR_API_TOKEN --secretOr using environment variables:
export LOGTAIL_API_TOKEN="your-api-token"Quick Start
import * as pulumi from "@pulumi/pulumi";
import * as logtail from "pulumi-logtail";
// Create a log source
const source = new logtail.Source("app-logs", {
name: "Application Logs",
platform: "docker",
});
export const sourceToken = source.token;Key Features
Log Sources
const dockerSource = new logtail.Source("docker", {
name: "Docker Containers",
platform: "docker",
});
const syslogSource = new logtail.Source("syslog", {
name: "System Logs",
platform: "syslog",
});Linking an AWS Account
For aws platform sources, attach the AWS account that Better Stack pulls logs
from with logtail.SourceAwsAccount (added in 10.14.0). Connect a new account
using the Better Stack CloudFormation stack outputs, or reuse one you've already
connected via awsAccountId:
const awsSource = new logtail.Source("aws-logs", {
name: "AWS Logs",
platform: "aws",
});
new logtail.SourceAwsAccount("aws-account", {
sourceId: awsSource.id,
awsRoleArn: "arn:aws:iam::123456789012:role/BetterStackIntegration",
awsExternalId: "cf-stack-external-id",
});Collectors and Targets
Collectors are agents that run inside your infrastructure to collect metrics from databases and processes. Use logtail.CollectorTarget (added in 10.11.3) to attach scrape targets to a collector:
const collector = new logtail.Collector("infra-collector", {
name: "Infra Collector",
dataRegion: "eu",
});
new logtail.CollectorTarget("postgres-primary", {
collectorId: collector.id,
kind: "postgres",
host: "db.internal",
port: 5432,
username: "metrics",
password: "secret",
});
new logtail.CollectorTarget("nginx-edge", {
collectorId: collector.id,
kind: "nginx",
collectorHost: "edge-01.internal",
endpoint: "http://127.0.0.1/nginx_status",
});Dashboards
const dashboard = new logtail.Dashboard("errors-overview", {
name: "Errors Overview",
});