Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Fix tutorial serieshelper #121

Merged
merged 3 commits into from
Mar 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions examples/tutorial_serieshelper.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
"""
Tutorial/Example how to use the class helper `SeriesHelper`
"""

from influxdb import InfluxDBClient
from influxdb import SeriesHelper

# InfluxDB connections settings
host = 'localhost'
port = 8086
user = 'root'
password = 'root'
dbname = 'mydb'

myclient = InfluxDBClient(host, port, user, password, dbname)

# Uncomment the following code if the database is not yet created
# myclient.create_database(dbname)
# myclient.create_retention_policy('awesome_policy', '3d', 3, default=True)


class MySeriesHelper(SeriesHelper):
# Meta class stores time series helper configuration.
class Meta:
# Meta class stores time series helper configuration.
client = InfluxDBClient()
# The client should be an instance of InfluxDBClient.
series_name = 'events.stats.{server_name}'
client = myclient
# The series name must be a string. Add dependent fields/tags in curly brackets.
fields = ['some_stat']
series_name = 'events.stats.{server_name}'
# Defines all the fields in this time series.
tags = ['server_name']
fields = ['some_stat', 'other_stat']
# Defines all the tags for the series.
bulk_size = 5
tags = ['server_name']
# Defines the number of data points to store prior to writing on the wire.
bulk_size = 5
# autocommit must be set to True when using bulk_size
autocommit = True


# The following will create *five* (immutable) data points.
# Since bulk_size is set to 5, upon the fifth construction call, *all* data
# points will be written on the wire via MySeriesHelper.Meta.client.
MySeriesHelper(server_name='us.east-1', some_stat=159)
MySeriesHelper(server_name='us.east-1', some_stat=158)
MySeriesHelper(server_name='us.east-1', some_stat=157)
MySeriesHelper(server_name='us.east-1', some_stat=156)
MySeriesHelper(server_name='us.east-1', some_stat=155)
MySeriesHelper(server_name='us.east-1', some_stat=159, other_stat=10)
MySeriesHelper(server_name='us.east-1', some_stat=158, other_stat=20)
MySeriesHelper(server_name='us.east-1', some_stat=157, other_stat=30)
MySeriesHelper(server_name='us.east-1', some_stat=156, other_stat=40)
MySeriesHelper(server_name='us.east-1', some_stat=155, other_stat=50)

# To manually submit data points which are not yet written, call commit:
MySeriesHelper.commit()
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy