-
Notifications
You must be signed in to change notification settings - Fork 7
InfluxDB Publisher v2 Agent #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d3c03d3
influx publisher v2 agent
davidvng ff15290
add docs
davidvng eb83571
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 437d122
cleanup
davidvng 28be7d2
Merge branch 'main' into influxdb-publisher-v2
davidvng e9e5073
Merge branch 'influxdb-publisher-v2' of github.com:simonsobs/ocs into…
davidvng fde5a63
common influxdb drivers; connection robustness; cleanup influxdb_publ…
davidvng 53054b5
Merge branch 'main' into influxdb-publisher-v2
davidvng b2974e3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 575a6b6
remove unused imports
davidvng f898d03
remove synchronous writetype; fix drivers test; cleanup docs
davidvng 775fa51
Merge branch 'main' into influxdb-publisher-v2
davidvng 1732272
remove unused import
davidvng 4f11e26
fix pytest
davidvng 56b26ea
fix drivers test
davidvng ca3b7ee
Wrap long lines
BrianJKoopman f043965
Remove old agent args from example
BrianJKoopman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| .. highlight:: rst | ||
|
|
||
| .. _influxdb_publisher_v2: | ||
|
|
||
| ======================== | ||
| InfluxDB Publisher v2 Agent | ||
| ======================== | ||
|
|
||
| The InfluxDB Publisher v2 Agent is an upgraded InfluxDB Publisher Agent that | ||
| uses the influxdb-client package instead of influxdb package to work with | ||
| InfluxDB v2. | ||
|
|
||
| .. argparse:: | ||
| :module: ocs.agents.influxdb_publisher_v2.agent | ||
| :func: make_parser | ||
| :prog: agent.py | ||
|
|
||
| Configuration File Examples | ||
| --------------------------- | ||
|
|
||
| Below are configuration examples for the ocs config file and for running the | ||
| Agent in a docker container. Also included is an example for setting up | ||
| Grafana to display data from InfluxDB. | ||
|
|
||
| OCS Site Config | ||
| ``````````````` | ||
|
|
||
| Add an InfluxDBAgent to your OCS configuration file:: | ||
|
|
||
| {'agent-class': 'InfluxDBAgentv2', | ||
| 'instance-id': 'influxagent', | ||
| 'arguments': ['--initial-state', 'record']}, | ||
|
|
||
| Docker Compose | ||
| `````````````` | ||
|
|
||
| Add the InfluxDB Publisher v2 Agent container to your docker-compose file:: | ||
|
|
||
| ocs-influxdb-publisher-v2: | ||
| image: simonsobs/ocs:latest | ||
| hostname: ocs-docker | ||
| environment: | ||
| - INSTANCE_ID=influxagent | ||
| volumes: | ||
| - ${OCS_CONFIG_DIR}:/config:ro | ||
| env_file: | ||
| - .env | ||
|
|
||
| Your .env file should contain credentials for the InfluxDB v2 database:: | ||
|
|
||
| INFLUXDB_V2_URL=http://influxdb:8086 | ||
| INFLUXDB_V2_ORG=ocs | ||
| INFLUXDB_V2_BUCKET=ocs_feeds | ||
| INFLUXDB_V2_TOKEN=<your-token> | ||
|
|
||
| You will also need an instance of InfluxDB v2 running somewhere on your network. | ||
| This likely should go in a separate docker-compose file so that it remains | ||
| online at all times. An example compose file would look like:: | ||
|
|
||
| services: | ||
| influxdb: | ||
| image: "influxdb:2.7" | ||
| container_name: "influxdb" | ||
| restart: always | ||
| ports: | ||
| - "8086:8086" | ||
| environment: | ||
| - INFLUXDB_HTTP_LOG_ENABLED=false | ||
| volumes: | ||
| - /srv/influxdb2:/var/lib/influxdb2 | ||
|
|
||
| networks: | ||
| default: | ||
| external: | ||
| name: ocs-net | ||
|
|
||
| .. note:: | ||
| This separate docker-compose file setup depends on having a docker network | ||
| that connects your various docker-compose files. On a single-node setup | ||
| this can be accomplished with the network settings above in each docker-compose | ||
| file. | ||
|
|
||
| You then need to create the docker network with:: | ||
|
|
||
| $ docker network create --driver bridge ocs-net | ||
|
|
||
| Containers on the network should then be able to communicate. | ||
|
|
||
| For more information about configuring Docker Compose files, see the `Compose | ||
| file reference`_. | ||
|
|
||
| .. _`Compose file reference`: https://docs.docker.com/compose/compose-file/ | ||
|
|
||
| Database Migration | ||
| `````````````````` | ||
|
|
||
| Follow instructions to `Upgrade from InfluxDB 1.x to 2.7 with Docker <upgrade_>`_. | ||
|
|
||
| .. _`upgrade`: https://docs.influxdata.com/influxdb/v2/install/upgrade/v1-to-v2/docker/ | ||
|
|
||
| Grafana | ||
BrianJKoopman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``````` | ||
|
|
||
| Once your InfluxDB v2 container and publisher are configured and running you will | ||
| need to create an InfluxDB data source in Grafana. To do so, we add an InfluxDB | ||
| data source with the URL ``http://influxdb:8086``, and the Database | ||
| (default "ocs_feeds", but this can be customized in your OCS config file.) The | ||
| Name of the Data Source is up to you, in this example we set it to "OCS Feeds". | ||
| Note that if you migrated from InfluxDB 1.x to 2.7, this process is slightly | ||
| different from adding an InfluxDB 1.x data source, as the auth token is required. | ||
|
|
||
| Follow instructions to `Configure your InfluxDB connection <configure_>`_ for InfluxDB v2. | ||
|
|
||
| .. _`configure`: https://docs.influxdata.com/influxdb/v2/tools/grafana/?t=InfluxQL#configure-your-influxdb-connection | ||
|
|
||
| .. note:: | ||
| The "ocs_feeds" database (or whatever you choose to name the database) will | ||
| not exist until the first time the InfluxDB Publisher Agent has successfully | ||
| connected to the InfluxDB. | ||
|
|
||
| For more information about using InfluxDB in Grafana, see the `Grafana Documentation`_. | ||
|
|
||
| .. _`Grafana Documentation`: https://grafana.com/docs/features/datasources/influxdb/ | ||
|
|
||
| Agent API | ||
| --------- | ||
|
|
||
| .. autoclass:: ocs.agents.influxdb_publisher_v2.agent.InfluxDBAgentv2 | ||
| :members: | ||
|
|
||
|
|
||
| Supporting APIs | ||
| --------------- | ||
|
|
||
| .. autoclass:: ocs.agents.influxdb_publisher_v2.agent.Publisher | ||
| :members: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.