This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch rel/0.12
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 028839f  [IOTDB-1805][to rel/0.12]iotdb-grafana-dockerfile (#4201)
028839f is described below

commit 028839f13c392fcf98b6a2f61b5f4470c470855e
Author: ZhangHongYin <[email protected]>
AuthorDate: Thu Oct 21 16:01:52 2021 +0800

    [IOTDB-1805][to rel/0.12]iotdb-grafana-dockerfile (#4201)
    
    * add iotdb-grafana-dockerfile
---
 docker/ReadMe.md                                   | 44 +++++++++++++++++++
 .../main/DockerCompose/docker-compose-grafana.yml  | 50 ++++++++++++++++++++++
 docker/src/main/Dockerfile-0.12.2-grafana          | 41 ++++++++++++++++++
 3 files changed, 135 insertions(+)

diff --git a/docker/ReadMe.md b/docker/ReadMe.md
index a416dd3..5e206de 100644
--- a/docker/ReadMe.md
+++ b/docker/ReadMe.md
@@ -66,4 +66,48 @@ docker exec -it c82321c70137 /bin/bash
 
 Then, for the latest version (or, >=0.10.x), run `start-cli.sh`, for version 
0.9.x and 0.8.1, run `start-client.sh`.
 
+# How to run IoTDB-grafana-connector
+
+1. First way: use config file:
+
+```
+docker run -it -v /your_application.properties_folder:/iotdb-grafana/config -p 
8888:8888 apache/iotdb:<version>-grafana
+```
+
+2. Second way: use environment(take `SPRING_DATASOURCE_URL` for example)
+
+```
+docker run -it -p 8888:8888 apache/iotdb:<version>-grafana -e 
SPRING_DATASOURCE_URL=jdbc:iotdb://iotdb:6667/
+```
+
+3. All related environment are as follows(more details in 
`grafana/src/main/resources/application.properties`)
+
+| name                                | default value                     |
+| ----------------------------------- | --------------------------------- |
+| SPRING_DATASOURCE_URL               | jdbc:iotdb://127.0.0.1:6667/      |
+| SPRING_DATASOURCE_USERNAME          | root                              |
+| SPRING_DATASOURCE_PASSWORD          | root                              |
+| SPRING_DATASOURCE_DRIVER_CLASS_NAME | org.apache.iotdb.jdbc.IoTDBDriver |
+| SERVER_PORT                         | 8888                              |
+| TIMESTAMP_PRECISION                 | ms                                |
+| ISDOWNSAMPLING                      | true                              |
+| INTERVAL                            | 1m                                |
+| CONTINUOUS_DATA_FUNCTION            | AVG                               |
+| DISCRETE_DATA_FUNCTION              | LAST_VALUE                        |
+
+# How to run IoTDB-grafana-connector by docker compose
+> Using docker compose, it contains three services: iotdb, grafana and 
grafana-connector
+
+1. The location of docker compose file: 
`/docker/src/main/DockerCompose/docker-compose-grafana.yml`
+2. Use `docker-compose up` can start all three services
+   1. you can use `docker-compose up -d` to start in the background
+   2. you can modify `docker-compose-grafana.yml` to implement your 
requirements.
+      1. you can modify environment of grafana-connector
+      2. If you want to **SAVE ALL DATA**, please use `volumes` keyword to 
mount the data volume or file of the host into the container.
+3. After all services are start, you can visit `{ip}:3000` to visit grafana
+   1. In `Configuration`, search `SimpleJson`
+   2. Fill in url: `grafana-connector:8888`, then click `save and test`. if 
`Data source is working` is shown, the configuration is finished.
+   3. Then you can create dashboards.
+4. if you want to stop services, just run `docker-compose down`
+
 Enjoy it!
diff --git a/docker/src/main/DockerCompose/docker-compose-grafana.yml 
b/docker/src/main/DockerCompose/docker-compose-grafana.yml
new file mode 100644
index 0000000..bd80ff7
--- /dev/null
+++ b/docker/src/main/DockerCompose/docker-compose-grafana.yml
@@ -0,0 +1,50 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+version: "2"
+
+services:
+    iotdb:
+      image: apache/iotdb
+      ports:
+        - 6667:6667
+      container_name: "iotdb"
+    grafana:
+      image: grafana/grafana
+      ports:
+        - 3000:3000
+      environment:
+        - GF_INSTALL_PLUGINS=grafana-simple-json-datasource
+      container_name: "grafana"
+    grafana-connector:
+      image: apache/iotdb:0.12.2-grafana
+      environment:
+        - SPRING_DATASOURCE_URL=jdbc:iotdb://iotdb:6667/
+        - SPRING_DATASOURCE_USERNAME=root
+        - SPRING_DATASOURCE_PASSWORD=root
+        - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.apache.iotdb.jdbc.IoTDBDriver
+        - SERVER_PORT=8888
+        - TIMESTAMP_PRECISION=ms
+        - ISDOWNSAMPLING=true
+        - INTERVAL=1m
+        - CONTINUOUS_DATA_FUNCTION=AVG
+        - DISCRETE_DATA_FUNCTION=LAST_VALUE
+      ports:
+        - 8888:8888
+      container_name: "grafana-connector"
diff --git a/docker/src/main/Dockerfile-0.12.2-grafana 
b/docker/src/main/Dockerfile-0.12.2-grafana
new file mode 100644
index 0000000..45c49cf
--- /dev/null
+++ b/docker/src/main/Dockerfile-0.12.2-grafana
@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+FROM openjdk:11-jre-slim
+RUN apt update \
+  # procps is for `free` command
+  && apt install wget unzip lsof procps -y \
+  && wget 
https://downloads.apache.org/iotdb/0.12.2/apache-iotdb-0.12.2-grafana-bin.zip \
+  # if you are in China, use the following URL
+  #&& wget 
https://mirrors.tuna.tsinghua.edu.cn/apache/iotdb/0.12.2/apache-iotdb-0.12.2-grafana-bin.zip
 \
+  && unzip apache-iotdb-0.12.2-grafana-bin.zip \
+  && rm apache-iotdb-0.12.2-grafana-bin.zip \
+  && mv apache-iotdb-0.12.2-grafana-bin /iotdb-grafana \
+  && apt remove wget unzip -y \
+  && apt autoremove -y \
+  && apt purge --auto-remove -y \
+  && apt clean -y
+# rpc port
+EXPOSE 8888
+VOLUME /iotdb-grafana/config
+RUN echo "#!/bin/bash" > /iotdb-grafana/runboot.sh
+RUN echo "java -Djava.security.egd=file:/dev/./urandom -jar 
/iotdb-grafana/iotdb-grafana.war" >> /iotdb-grafana/runboot.sh
+RUN chmod a+x /iotdb-grafana/runboot.sh
+WORKDIR /iotdb-grafana
+ENTRYPOINT ["./runboot.sh"]

Reply via email to