Skip to main content

A streaming pipeline that transforms PubSub messages into metrics using Apache Beam

Project description

Beametrics

Let your logs be metrics in real-time with Apache Beam.

Beametrics transfers structured messages from a queue into metrics in real-time. Primarily designed to work with Cloud Pub/Sub to export metrics to Cloud Monitoring.

Usage

Direct Runner

$ python -m beametrics.main \
  --project=YOUR_PROJECT_ID \
  --subscription=projects/YOUR_PROJECT_ID/subscriptions/YOUR_SUBSCRIPTION \
  --metric-name=YOUR_METRIC_NAME \
  --metric-labels='{"LABEL": "HOGE"}' \
  --filter-conditions='[{"field": "user_agent", "value": "dummy_data", "operator": "equals"}]' \
  --runner=DirectRunner \
  --metric-type=count \
  --export-type=monitoring

Dataflow Runner

1. Build Docker image

$ docker build -t LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/beametrics:latest .

2. Push Docker image to Artifact Registry

$ docker push LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/beametrics:latest

3. Build Dataflow Flex Template

$ gcloud dataflow flex-template build gs://BUCKET/beametrics.json \
--image "LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/beametrics:latest" \
--sdk-language "PYTHON" \
--metadata-file "metadata.json"

4. Run Dataflow job

$ cat flags.yaml
--parameters:
  project-id: YOUR_PROJECT_ID
  subscription: projects/YOUR_PROJECT_ID/subscriptions/YOUR_SUBSCRIPTION
  metric-name: YOUR_METRIC_NAME
  metric-labels: '{"LABEL": "HOGE"}'
  filter-conditions: '[{"field":"user_agent","value":"dummy_data","operator":"equals"}]'
  metric-type: count
  window-size: "120"
$ gcloud dataflow flex-template run "beametrics-job-$(date +%Y%m%d-%H%M%S)" \
--template-file-gcs-location gs://BUCKET/beametrics.json \
--region REGION \
--flags-file=flags.yaml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beametrics-0.2.4.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beametrics-0.2.4-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file beametrics-0.2.4.tar.gz.

File metadata

  • Download URL: beametrics-0.2.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for beametrics-0.2.4.tar.gz
Algorithm Hash digest
SHA256 752879d96dcacc89c8c8e56766488c92284055968412e1b7076e2aa826740059
MD5 4354e13e7f0ee8911747f2c5f11f6e59
BLAKE2b-256 85c0e695ecbedd82aad0a3ef93f4795d31975b908609f7d8e3de0952a6832cee

See more details on using hashes here.

File details

Details for the file beametrics-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: beametrics-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for beametrics-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7e3bf2707fd3ee55df4e2f58d6ac586efc32fd32479c02e80ee5f082e3a45c2e
MD5 69dc8c439d5845a57349e7f0f1822e35
BLAKE2b-256 bd46e12861765b156f6c83f6f80f430343e66ae1ad0b2cb0b1ba2be35e4304da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page