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

Monitoring: support to change file persistence #13

Merged
merged 3 commits into from
Sep 25, 2019
Merged
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
2 changes: 1 addition & 1 deletion cmd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN chmod +x /usr/bin/init.sh

COPY dashboards/*.json /tmp/
COPY rules/*.rules.yml /tmp/
COPY datasources/*.json /tmp/
COPY datasources/*.yaml /tmp/

ENTRYPOINT ["/usr/bin/init.sh"]
CMD ["TIDB-Cluster", "/grafana-dashboard-definitions/tidb/", "false", "/etc/prometheus"]
14 changes: 0 additions & 14 deletions cmd/datasource/k8s-datasource.json

This file was deleted.

10 changes: 10 additions & 0 deletions cmd/datasource/k8s-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- access: proxy
editable: true
name: k8s-cluster
orgId: 1
type: prometheus
url: http://prometheus-k8s.monitoring.svc:9090
version: 1

14 changes: 0 additions & 14 deletions cmd/datasource/tidb-cluster-datasource.json

This file was deleted.

9 changes: 9 additions & 0 deletions cmd/datasource/tidb-cluster-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- access: proxy
editable: false
name: tidb-cluster
orgId: 1
type: prometheus
url: http://127.0.0.1:9090
version: 1
27 changes: 19 additions & 8 deletions cmd/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,37 @@ do
sed -i 's/ENV_LABELS_ENV/'$TIDB_CLUSTER_NAME'/g' $file
done

# Copy Persistent rules to override raw files
if [ ! -z $PROM_PERSISTENT_DIR ];
then
if [ -d $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/} ];then
cp -f $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/}/*.rules.yml $PROM_CONFIG_PATH/rules
fi
fi


# Datasources
if [ $GF_DATASOURCE_PATH ];
if [ ! -z $GF_DATASOURCE_PATH ];
then
if [ $GF_K8S_PROMETHEUS_URL ];
if [ ! -z $GF_K8S_PROMETHEUS_URL ];
then
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.json
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.yaml
fi

if [ $GF_TIDB_PROMETHEUS_URL ];
if [ ! -z $GF_TIDB_PROMETHEUS_URL ];
then
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.json
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.yaml
fi

cp /tmp/k8s-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/k8s-datasource.yaml $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.yaml $GF_DATASOURCE_PATH/

# pods
if [ $TIDB_CLUSTER_NAMESPACE ];
if [ ! -z $TIDB_CLUSTER_NAMESPACE ];
then
sed -i 's/$namespace/'$TIDB_CLUSTER_NAMESPACE'/g' /tmp/pods.json
else
sed -i 's/$namespace/default/g' /tmp/pods.json
fi
sed -i 's/Test-Cluster-Pods-Info/'$TIDB_CLUSTER_NAME'-Pods-Info/g' /tmp/pods.json
cp /tmp/pods.json $GF_PROVISIONING_PATH/dashboards
Expand Down
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ var (
//dockerfiles = []string{"Dockerfile", "init.sh"}

localFiles = map[string]string {
"datasource/k8s-datasource.json": "datasources",
"datasource/tidb-cluster-datasource.json": "datasources",
"datasource/k8s-datasource.yaml": "datasources",
"datasource/tidb-cluster-datasource.yaml": "datasources",
"dashboards/pods/pods.json": "dashboards",
"dashboards/nodes/nodes.json": "dashboards",
"Dockerfile": ".",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/hashicorp/go-version v1.2.0
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/common v0.4.1
github.com/prometheus/prometheus v0.0.0-20190710134608-e5b22494857d
github.com/rakyll/statik v0.1.6
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
Expand Down
2 changes: 1 addition & 1 deletion monitor/v2.1.10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN chmod +x /usr/bin/init.sh

COPY dashboards/*.json /tmp/
COPY rules/*.rules.yml /tmp/
COPY datasources/*.json /tmp/
COPY datasources/*.yaml /tmp/

ENTRYPOINT ["/usr/bin/init.sh"]
CMD ["TIDB-Cluster", "/grafana-dashboard-definitions/tidb/", "false", "/etc/prometheus"]
14 changes: 0 additions & 14 deletions monitor/v2.1.10/datasources/k8s-datasource.json

This file was deleted.

10 changes: 10 additions & 0 deletions monitor/v2.1.10/datasources/k8s-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- access: proxy
editable: true
name: k8s-cluster
orgId: 1
type: prometheus
url: http://prometheus-k8s.monitoring.svc:9090
version: 1

14 changes: 0 additions & 14 deletions monitor/v2.1.10/datasources/tidb-cluster-datasource.json

This file was deleted.

9 changes: 9 additions & 0 deletions monitor/v2.1.10/datasources/tidb-cluster-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- access: proxy
editable: false
name: tidb-cluster
orgId: 1
type: prometheus
url: http://127.0.0.1:9090
version: 1
27 changes: 19 additions & 8 deletions monitor/v2.1.10/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,37 @@ do
sed -i 's/ENV_LABELS_ENV/'$TIDB_CLUSTER_NAME'/g' $file
done

# Copy Persistent rules to override raw files
if [ ! -z $PROM_PERSISTENT_DIR ];
then
if [ -d $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/} ];then
cp -f $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/}/*.rules.yml $PROM_CONFIG_PATH/rules
fi
fi


# Datasources
if [ $GF_DATASOURCE_PATH ];
if [ ! -z $GF_DATASOURCE_PATH ];
then
if [ $GF_K8S_PROMETHEUS_URL ];
if [ ! -z $GF_K8S_PROMETHEUS_URL ];
then
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.json
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.yaml
fi

if [ $GF_TIDB_PROMETHEUS_URL ];
if [ ! -z $GF_TIDB_PROMETHEUS_URL ];
then
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.json
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.yaml
fi

cp /tmp/k8s-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/k8s-datasource.yaml $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.yaml $GF_DATASOURCE_PATH/

# pods
if [ $TIDB_CLUSTER_NAMESPACE ];
if [ ! -z $TIDB_CLUSTER_NAMESPACE ];
then
sed -i 's/$namespace/'$TIDB_CLUSTER_NAMESPACE'/g' /tmp/pods.json
else
sed -i 's/$namespace/default/g' /tmp/pods.json
fi
sed -i 's/Test-Cluster-Pods-Info/'$TIDB_CLUSTER_NAME'-Pods-Info/g' /tmp/pods.json
cp /tmp/pods.json $GF_PROVISIONING_PATH/dashboards
Expand Down
2 changes: 1 addition & 1 deletion monitor/v2.1.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN chmod +x /usr/bin/init.sh

COPY dashboards/*.json /tmp/
COPY rules/*.rules.yml /tmp/
COPY datasources/*.json /tmp/
COPY datasources/*.yaml /tmp/

ENTRYPOINT ["/usr/bin/init.sh"]
CMD ["TIDB-Cluster", "/grafana-dashboard-definitions/tidb/", "false", "/etc/prometheus"]
14 changes: 0 additions & 14 deletions monitor/v2.1.11/datasources/k8s-datasource.json

This file was deleted.

10 changes: 10 additions & 0 deletions monitor/v2.1.11/datasources/k8s-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- access: proxy
editable: true
name: k8s-cluster
orgId: 1
type: prometheus
url: http://prometheus-k8s.monitoring.svc:9090
version: 1

14 changes: 0 additions & 14 deletions monitor/v2.1.11/datasources/tidb-cluster-datasource.json

This file was deleted.

9 changes: 9 additions & 0 deletions monitor/v2.1.11/datasources/tidb-cluster-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- access: proxy
editable: false
name: tidb-cluster
orgId: 1
type: prometheus
url: http://127.0.0.1:9090
version: 1
27 changes: 19 additions & 8 deletions monitor/v2.1.11/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,37 @@ do
sed -i 's/ENV_LABELS_ENV/'$TIDB_CLUSTER_NAME'/g' $file
done

# Copy Persistent rules to override raw files
if [ ! -z $PROM_PERSISTENT_DIR ];
then
if [ -d $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/} ];then
cp -f $PROM_PERSISTENT_DIR/latest-rules/${TIDB_VERSION##*/}/*.rules.yml $PROM_CONFIG_PATH/rules
fi
fi


# Datasources
if [ $GF_DATASOURCE_PATH ];
if [ ! -z $GF_DATASOURCE_PATH ];
then
if [ $GF_K8S_PROMETHEUS_URL ];
if [ ! -z $GF_K8S_PROMETHEUS_URL ];
then
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.json
sed -i 's,http://prometheus-k8s.monitoring.svc:9090,'$GF_K8S_PROMETHEUS_URL',g' /tmp/k8s-datasource.yaml
fi

if [ $GF_TIDB_PROMETHEUS_URL ];
if [ ! -z $GF_TIDB_PROMETHEUS_URL ];
then
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.json
sed -i 's,http://127.0.0.1:9090,'$GF_TIDB_PROMETHEUS_URL',g' /tmp/tidb-cluster-datasource.yaml
fi

cp /tmp/k8s-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.json $GF_DATASOURCE_PATH/
cp /tmp/k8s-datasource.yaml $GF_DATASOURCE_PATH/
cp /tmp/tidb-cluster-datasource.yaml $GF_DATASOURCE_PATH/

# pods
if [ $TIDB_CLUSTER_NAMESPACE ];
if [ ! -z $TIDB_CLUSTER_NAMESPACE ];
then
sed -i 's/$namespace/'$TIDB_CLUSTER_NAMESPACE'/g' /tmp/pods.json
else
sed -i 's/$namespace/default/g' /tmp/pods.json
fi
sed -i 's/Test-Cluster-Pods-Info/'$TIDB_CLUSTER_NAME'-Pods-Info/g' /tmp/pods.json
cp /tmp/pods.json $GF_PROVISIONING_PATH/dashboards
Expand Down
2 changes: 1 addition & 1 deletion monitor/v2.1.12/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN chmod +x /usr/bin/init.sh

COPY dashboards/*.json /tmp/
COPY rules/*.rules.yml /tmp/
COPY datasources/*.json /tmp/
COPY datasources/*.yaml /tmp/

ENTRYPOINT ["/usr/bin/init.sh"]
CMD ["TIDB-Cluster", "/grafana-dashboard-definitions/tidb/", "false", "/etc/prometheus"]
14 changes: 0 additions & 14 deletions monitor/v2.1.12/datasources/k8s-datasource.json

This file was deleted.

10 changes: 10 additions & 0 deletions monitor/v2.1.12/datasources/k8s-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1
datasources:
- access: proxy
editable: true
name: k8s-cluster
orgId: 1
type: prometheus
url: http://prometheus-k8s.monitoring.svc:9090
version: 1

14 changes: 0 additions & 14 deletions monitor/v2.1.12/datasources/tidb-cluster-datasource.json

This file was deleted.

Loading