Skip to content
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

Enable influxdb basic Auth settings #383

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 13 additions & 4 deletions docker/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: "3.6"

services:
loudml:
image: loudml/loudml:1.6.0
image: loudml/loudml
volumes:
- ./etc/loudml.yml:/etc/loudml/config.yml:ro
- var_loudml
Expand All @@ -14,11 +14,16 @@ services:
- influxdb

influxdb:
image: influxdb
image: influxdb:alpine
ports:
- "8086:8086"
volumes:
- var_influxdb
- ./etc/influx_init.iql:/docker-entrypoint-initdb.d/influx_init.iql
environment:
INFLUXDB_HTTP_AUTH_ENABLED: "true"
INFLUXDB_ADMIN_USER: "admin"
INFLUXDB_ADMIN_PASSWORD: "passw0rd"

chronograf:
image: loudml/chronograf
Expand All @@ -31,21 +36,25 @@ services:
volumes:
- var_chronograf
environment:
INFLUXDB_USERNAME: "admin"
INFLUXDB_PASSWORD: "passw0rd"
INFLUXDB_URL: http://influxdb:8086
LOUDML_URL: http://loudml:8077
KAPACITOR_URL: http://kapacitor:9092

kapacitor:
image: kapacitor
image: kapacitor:alpine
depends_on:
- influxdb
volumes:
- var_kapacitor
environment:
KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:8086
KAPACITOR_INFLUXDB_0_USERNAME: "admin"
KAPACITOR_INFLUXDB_0_PASSWORD: "passw0rd"

telegraf:
image: telegraf
image: telegraf:alpine
volumes:
- ./etc/telegraf.conf:/etc/telegraf/telegraf.conf:ro
depends_on:
Expand Down
14 changes: 14 additions & 0 deletions docker/compose/etc/influx_init.iql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE DATABASE "telegraf"
CREATE DATABASE "loudml"
CREATE DATABASE "chronograf"
CREATE USER telegraf WITH PASSWORD 'metricsmetricsmetricsmetrics'
REVOKE ALL PRIVILEGES FROM telegraf
GRANT WRITE ON telegraf TO telegraf
CREATE USER reader WITH PASSWORD 'metricsmetricsmetricsmetrics'
REVOKE ALL PRIVILEGES FROM reader
GRANT READ ON telegraf TO reader
GRANT READ ON chronograf TO reader
CREATE USER loudml WITH PASSWORD 'metricsmetricsmetricsmetrics'
REVOKE ALL PRIVILEGES FROM loudml
GRANT WRITE ON loudml TO loudml
GRANT ALL ON chronograf TO loudml
9 changes: 7 additions & 2 deletions docker/compose/etc/loudml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ buckets:
type: influxdb
addr: influxdb:8086
database: loudml
dbuser: loudml
dbuser_password: "metricsmetricsmetricsmetrics"
retention_policy: autogen
measurement: loudml
create_database: false
- name: data
type: influxdb
addr: influxdb:8086
database: data
database: telegraf
dbuser: reader
dbuser_password: "metricsmetricsmetricsmetrics"
retention_policy: autogen
measurement: sinus
create_database: false

storage:
path: /var/lib/loudml
Expand Down
4 changes: 2 additions & 2 deletions docker/compose/etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
# timeout = "5s"

## HTTP Basic Auth
# username = "telegraf"
# password = "metricsmetricsmetricsmetrics"
username = "telegraf"
password = "metricsmetricsmetricsmetrics"

## HTTP User-Agent
# user_agent = "telegraf"
Expand Down
12 changes: 10 additions & 2 deletions loudml/influx.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ def annotationdb(self):
ssl=self.use_ssl,
verify_ssl=self.verify_ssl,
)
self._annotationdb.create_database(db)

return self._annotationdb

Expand Down Expand Up @@ -679,7 +678,16 @@ def list_anomalies(
)

query = ''.join(query)
result = self.annotationdb.query(query)
try:
result = self.annotationdb.query(query)
except influxdb.exceptions.InfluxDBClientError as exn:
logging.warning(
"could not load annotations, got error '%d'",
exn.code,
)
if exn.code == 401:
return []
raise exn

windows = []
for j, point in enumerate(result.get_points()):
Expand Down
2 changes: 1 addition & 1 deletion loudml/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def predict(
if detect_anomalies:
hooks = self.storage.load_model_hooks(
model.settings,
bucket,
output_bucket or bucket,
)
model.detect_anomalies(prediction, hooks)
if save_run_state:
Expand Down