Skip to Content
GuidesSend your first metric

Send Your First Metric

This guide picks up after the Quickstart. You’ll learn batching, tags, and events — the three features you’ll use most after the initial “hello world.”

Prerequisites

  • A Plexus account with an API key
  • Python 3.10+ and plexus-python installed (see Quickstart)

Step 1 — Send a batch

Batching multiple metrics in one request reduces network overhead, which matters on constrained hardware:

from plexus import Plexus px = Plexus(api_key="YOUR_API_KEY", source_id="robot-01") px.send_batch([ ("battery.voltage", 12.4), ("battery.current_ma", 340), ("sensor.temperature_c", 23.5), ("sensor.humidity_pct", 54.1), ("motor.rpm", 1200), ])

Metric naming convention: <subsystem>.<metric> — e.g. battery.voltage, motor.rpm, sensor.temperature_c. Consistent naming makes dashboard queries and alerts easier to build.

Step 2 — Verify

curl https://api.plexus.company/v1/sources/robot-01/metrics/latest \ -H "x-api-key: YOUR_API_KEY"
{ "metrics": { "battery.voltage": 12.4, "battery.current_ma": 340, "sensor.temperature_c": 23.5, "sensor.humidity_pct": 54.1, "motor.rpm": 1200 } }

Step 3 — Add tags

Tags let you slice data by firmware version, location, or any dimension:

px.send("sensor.temperature_c", 23.5, tags={ "location": "warehouse-a", "firmware": "1.4.2", })

Tags are indexed and queryable — keep them low-cardinality (not UUIDs or timestamps).

Step 4 — Send events

For state changes, faults, or any non-numeric data, use data_class="event":

px.send("motor.state_change", {"from": "IDLE", "to": "RUNNING"}, data_class="event") px.send("device.fault", {"code": "E_MOTOR_STALL", "sensor": "encoder"}, data_class="event")

Events appear in the Logs endpoint, separate from numeric metrics.

Next steps

Last updated on