Advanced Usage
You’ll find advanced ways of using Felicien.
TSDB Authentication
FeliConnector is based on Requests to communicate with the TSDB. As such, it allows to pass Requests parameters to the FeliConnector constructor, to be used in all the HTTP requests. For example, this is how you can authenticate your calls to the TSDB:
>>> from requests.auth import HTTPBasicAuth
>>> tsdb = FeliConnector(url="http://victoriametrics:8428", tsdb="victoriametrics", options={"auth": HTTPBasicAuth("foo", "bar")})
In all the calls to the TSDB, the option auth=HTTPBasicAuth("foo", "bar") will be used.
TLS Management
Just like the Authentication, you can pass Requests TLS configuration to the FeliConnector constructor.
TLS Verification
You can pass a CA_BUNDLE file, to verify the server certificate with your prefered trusted CA:
>>> tsdb = FeliConnector(url="http://victoriametrics:8428", tsdb="victoriametrics", options={"verify": "/path/to/certfile"})
Or you can disable TLS verification:
>>> tsdb = FeliConnector(url="http://victoriametrics:8428", tsdb="victoriametrics", options={"verify": False})
Client certificates
You can also use a client certificate:
>>> tsdb = FeliConnector(url="http://victoriametrics:8428", tsdb="victoriametrics", options={"cert": ('/path/client.cert', '/path/client.key')})
Apply changes to timeserie
You may want to produce your own timeserie, and push it to a TSDB.
Let’s start by creating your own FeliTS object:
>>> import pandas as pd
>>> import math
>>> idx = pd.DatetimeIndex([pd.to_datetime(1710231704+x*60, unit="s") for x in range(2880)])
>>> ser = pd.Series(data=[math.cos(math.radians(x)) for x in range(2880)], index=idx)
>>> ts = FeliTS(name="mymetric", labels={"mylabel": "myvalue"}, values=ser)
>>> ts
FeliTS(mymetric{mylabel:"myvalue"}, 2880 datapoints)
This metric could be pushed to the TSDB via a FeliConnector object:
>>> tsdb = FeliConnector(url="http://victoriametrics:8428", tsdb="victoriametrics")
>>> tsdb.import_timeserie(ts=ts)
Plotting the timeserie
You may need a visual representation of your metric (using Matplotlib):
>>> import pandas as pd
>>> import math
>>> idx = pd.DatetimeIndex([pd.to_datetime(1710231704+x*60, unit="s") for x in range(2880)])
>>> ser = pd.Series(data=[math.cos(math.radians(x)) for x in range(2880)], index=idx)
>>> ts = FeliTS(name="mymetric", labels={"mylabel": "myvalue"}, values=ser)
>>> ts.plot()
This should open a window:
TSDB type
When creating your FeliConnector object, you can specify the TSDB type (so that the URLs to access the different endpoints are localized).
Possible values are:
prometheusvictoriametrics
Note
Only single-node victoriametrics is currently supported. The cluster version uses different API endpoint, and is not currently compatible.