Skip to main content

An adapter to connect mosaik with InfluxDB 2

Project description

mosaik-influxdb2

This package contains an adapter to write data from a mosaik simulation into an InfluxDB 2 database.

Installation

This package is on pypi, so you can install it using pip:

pip install mosaik-influxdb2

Usage

To use the simulator, first add it to your sim_config:

sim_config = {
    "InfluxWriter": {"python": "mosaik.components.influxdb2.writer:Simulator"},
    # ...
}

Next, you need to start the simulator. Here, you have two choices to make:

  1. The simulator can run both in time-based mode with a fixed step size or in event-based mode without a step size. You can choose the time-based mode by giving the parameter step_size when starting the simulator. If you give step_size=None (or don’t specify anything), the simulator will use the event-based mode.
  2. You can either supply a start date (as a string parseable by Python’s datetime module) which will be combined with the (mosaik) time and time resolution to calculate each step’s time, or you can supply the time for each step on the local_time attribute (again, as a string). If you give both, the value on the local_time attribute will take precedence.

So one possible invocation would be

influx_sim = world.start("InfluxWriter",
    step_size=900,
    start_date="2022-01-01 00:00:00Z",
)

to start the simulator in time-based mode with a step size of 900 and times based on the given start date. You can leave off either argument with the effects described above.

Finally, the model needs to be started with your Influx credentials:

influx = influx_sim.Database(
    url="http://localhost:8086",
    org='.',
    bucket='my_bucket',
    token='secret_token',
    measurement='experiment_0001'
)

We recommend setting a new value for the measurement on each simulation run. (For example, you can use the start time of your simulation or a random UUID.)

Afterwards, you can define world.connect(other_entity, influx, attrs) as you like.

The simulator supports only one instance of the Database model. If you want to connect to several databases, you will need to start several instances of the simulator as well.

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

mosaik_influxdb2-0.2.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

mosaik_influxdb2-0.2.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file mosaik_influxdb2-0.2.0.tar.gz.

File metadata

  • Download URL: mosaik_influxdb2-0.2.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.10 Linux/5.4.109+

File hashes

Hashes for mosaik_influxdb2-0.2.0.tar.gz
Algorithm Hash digest
SHA256 eb4540023c19e66c9aaa75cc4d3526fccf771e04a815739e9cc49adad86f6b72
MD5 fed3c16cfcd84d00551e6e1b017744e9
BLAKE2b-256 7be1926f946744103abf872c5c212d9774692e0f646991b6cea93987bd675afd

See more details on using hashes here.

File details

Details for the file mosaik_influxdb2-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mosaik_influxdb2-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.10 Linux/5.4.109+

File hashes

Hashes for mosaik_influxdb2-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78ab34837aa1bde92f41d8913c6a8205548446c120cafa319448ec82c17de34a
MD5 5a2b0c67703b3660929afc1788b3496a
BLAKE2b-256 ba720cbffc10dcfbd4d98eef43b0f44755941e123d1850e2661c46985ecceed3

See more details on using hashes here.

Supported by

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