Class CirconusSubmit¶
This class provides methods to submit data to Circonus via a HTTPTrap check.
Example¶
from circonusapi import circonussubmit
# Option A: Create a new check to submit data to
sub = circonussubmit.CirconusSubmit()
sub.auth("65669d6b-edfe-4ede-bc51-7f3cae6419cf")
sub.check_create("circ-submit-1")
# Option B: Use a existing submission URL:
sub = circonussubmit.CirconusSubmit("<submission url>")
# Add data to batch
from datetime import datetime
sub.add_number(datetime(2020, 1, 1, 0, 0, 0), "test-metric-1", 20)
sub.add_number(datetime(2020, 1, 1, 0, 1, 0), "test-metric-1", 40)
sub.add_number(datetime(2020, 1, 1, 0, 2, 0), "test-metric-1", 50)
# Submit batch of data
sub.submit()
-
class
circonusapi.circonussubmit.
CirconusSubmit
(url=None)¶ Create CirconusSubmit Object
- Args:
url (str, optional): URL to submit data to
-
add_histogram
(ts, name, hist)¶ Add a histogram value to next batch.
- Args:
ts (number): Timestamp in seconds since epoch, or “now” as a string.
name (str): Metric name, including stream tags.
value (CircllHist): value to submit.
-
add_number
(ts, name, value)¶ Add a numeric value to next batch.
- Args:
ts (number): Timestamp in seconds since epoch.
name (str): Metric name, including stream tags.
value (number): value to submit.
-
auth
(token)¶ Authenticate to the API with given token
- Args:
token (str): API token
-
check_create
(name)¶ Create new HTTPTrap check with given name, and set submission url accordingly. Requires .auth() to be called beforehand.
- Args:
name (str): Name of check to create
-
submit
()¶ submit a batch of data