promsentry

package module
v0.0.0-...-ce06de6 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

README

Promsentry

Bring your Prometheus data to Sentry via DDM.

Promsentry acts as a Prometheus remote writer receiver (or a remote write server if you say), that ingest the data and push it into Sentry's DDM, basically just converting Prometheus' protobuf format into Sentry's accepted StatsD format.

Installation

As of now, I don't provide any other way than to build the binary yourself.

  1. Make sure you installed Go (minimum version of 1.21)
  2. Run go build -ldflags="-s -w" -o promsentry ./cmd
  3. Copy the promsentry binary into somewhere, for /usr/local/bin/ you can do sudo install promsentry /usr/local/bin/promsentry.

Running the application

Simply just invoke promsentry binary with some environment variables or configuration file. On your Prometheus configuration, points the remote write target to the {LISTEN_ADDRESS}/api/v1/write

Here are some instructionS if you want to try around with local Prometheus Docker image.

Without Sentry instance
  1. Start local Prometheus server, simply by doing docker compose up -d. It will spawn a local Prometheus server on 127.0.0.1:9090.
  2. Then run the promsentry binary using go run ./cmd. It will start the server at 127.0.0.1:3000.
  3. See the debug log on your terminal.
With real Sentry instance
  1. Start local Prometheus server like the instruction above.
  2. Set SENTRY_DSN on your environment variable to a valid Sentry DSN.
  3. Then run the promsentry binary using go run ./cmd. It will start the server at 127.0.0.1:3000.
  4. Make sure the debug log on your terminal correctly sends some data.
  5. Observe everything on your Sentry dashboard.

Configuration

The program accepts 2 kinds of configuration:

  1. Configuration file (JSON or YAML format)
  2. Environment variables
Configuration File

Start promsentry using --config-file=./path/to/config.json or CONFIG_FILE=./path/to/config.yml promsentry.

Refer to the schema and example values below. Every field is optional.

{
    "listen_address": "127.0.0.1:3000",
    "sentry_dsn": "https://xxxxxx@o123456.ingest.sentry.io/123456",
    "tls": {
        "certificate_authority_path": "./path/to/ca.pem",
        "server_certificate_path": "./path/to/cert.pem",
        "server_key_path": "./path/to/key.pem",
        "client_authentication_type": "VerifyClientCertIfGiven"
    },
    "debug": false
}
listen_address: "127.0.0.1:3000"
sentry_dsn: "https://xxxxxx@o123456.ingest.sentry.io/123456"
tls:
    certificate_authority_path: "./path/to/ca.pem",
    server_certificate_path: "./path/to/cert.pem",
    server_key_path: "./path/to/key.pem",
    client_authentication_type: "VerifyClientCertIfGiven"
debug: false
Environment variables
  • LISTEN_ADDRESS
  • TLS_CERTIFICATE_AUTHORITY_PATH
  • TLS_SERVER_CERTIFICATE_PATH
  • TLS_SERVER_KEY_PATH
  • TLS_CLIENT_AUTHENTICATION_TYPE
  • SENTRY_DSN
  • DEBUG

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTLSConfiguration

func CreateTLSConfiguration(serverCertPath string, serverKeyPath string, clientCARootPath string, clientAuthenticationType string) (*tls.Config, error)

CreateTLSConfiguration process the paths to certificate and the client authentication type based on the values on the function parameter, then create a *tls.Config struct that can be passed to multiple stuff. Some of them being the HTTP server or gRPC server.

Please do not insert empty string values for each function parameter. You will get an error instead.

func NewServer

func NewServer(listenAddress string, tlsConfig *tls.Config) (*http.Server, error)

Types

type Configuration

type Configuration struct {
	ListenAddress string `json:"listen_address" yaml:"listen_address"`
	TLS           struct {
		CertificateAuthorityPath string `json:"certificate_authority_path" yaml:"certificate_authority_path"`
		ServerCertificatePath    string `json:"server_certificate_path" yaml:"server_certificate_path"`
		ServerKeyPath            string `json:"server_key_path" yaml:"server_key_path"`
		ClientAuthenticationType string `json:"client_authentication_type" yaml:"client_authentication_type"`
	} `json:"tls" yaml:"tls"`
	SentryDsn string `json:"sentry_dsn" yaml:"sentry_dsn"`
	Debug     bool   `json:"debug" yaml:"debug"`
}

func ParseConfiguration

func ParseConfiguration(filePath string) (*Configuration, error)

Directories

Path Synopsis
Package sentry is a heavily modified Go SDK for Sentry dedicated just for Delightful Developer Metrics (DDM), or at least that's the name when I was working on this program.
Package sentry is a heavily modified Go SDK for Sentry dedicated just for Delightful Developer Metrics (DDM), or at least that's the name when I was working on this program.

Jump to

Keyboard shortcuts

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