-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
[timeseries] Add initial support for elasticsearch #99 #164
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ services: | |
depends_on: | ||
- influxdb | ||
- redis | ||
- es01 | ||
- es02 | ||
|
||
influxdb: | ||
image: influxdb:1.8-alpine | ||
|
@@ -22,6 +24,45 @@ services: | |
INFLUXDB_DB: openwisp2 | ||
INFLUXDB_USER: openwisp | ||
INFLUXDB_USER_PASSWORD: openwisp | ||
# clustered version of elasticsearch is used as that might be used in production | ||
es01: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to run Elasticsearch in a High Available environment. Testing HA capabilities is ElasticSearch's job 😃 . We can simply make sure that setting up a multi-nodes cluster works but IMHO it is enough for us to run tests in only one instance. WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree though there are some problems that I was facing with elasticsearch docker due to which too I am using two nodes 😅. Can you please check out if it's possible to run elasticsearch on a single port (I am not sure about this as I could not :/ ) and then I can adapt. Thanks! |
||
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 | ||
container_name: es01 | ||
environment: | ||
- "node.name=es01" | ||
- "discovery.seed_hosts=es02" | ||
- "cluster.initial_master_nodes=es01,es02" | ||
- "cluster.name=openwisp2" | ||
- "bootstrap.memory_lock=true" | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- esdata01:/usr/share/elasticsearch/data | ||
ports: | ||
- 9200:9200 | ||
networks: | ||
- esnet | ||
es02: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0 | ||
container_name: es02 | ||
environment: | ||
- "node.name=es02" | ||
- "discovery.seed_hosts=es01" | ||
- "cluster.initial_master_nodes=es01,es02" | ||
- "cluster.name=openwisp2" | ||
- "bootstrap.memory_lock=true" | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- esdata02:/usr/share/elasticsearch/data | ||
networks: | ||
- esnet | ||
|
||
redis: | ||
image: redis:5.0-alpine | ||
|
@@ -31,3 +72,10 @@ services: | |
|
||
volumes: | ||
influxdb-data: {} | ||
esdata01: | ||
driver: local | ||
esdata02: | ||
driver: local | ||
|
||
networks: | ||
esnet: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
from .backends import timeseries_db | ||
|
||
chart_query = timeseries_db.queries.chart_query | ||
default_chart_query = timeseries_db.queries.default_chart_query | ||
device_data_query = timeseries_db.queries.device_data_query | ||
|
||
__all__ = ['timeseries_db', 'chart_query', 'default_chart_query', 'device_data_query'] | ||
__all__ = ['timeseries_db', 'chart_query'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .queries import _make_query | ||
|
||
__all__ = ['_make_query'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you change the code so that calling this functon from the configuration is not necessary?
You can loop over the data structure and call it when it's initialized, this way we make things easy for users and we avoid them come to complain to us in the support channels 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that can be done and I have done the same for built-in charts.
_make_query
is just a utility function which will update the aggregation for adefault_chart_query
defined in openwisp_monitoring.db.backends.elasticsearch.queries. So queries returned via_make_query
will always retain the structure ofdefault_chart_query
.I wanted to leave the option of directly using a dsl query with
timeseries_db.query
, exactly like how we can query InfluxDB directly using the same function.A full dsl query will look like this,
So, if we make
_make_query
as a compulsion, we might be cutting down a user's freedom to query via DSL. Personally, I would like to give user this freedom (this would enable him to just put a query like above in chart configuration and it will work) 😄.