diff --git a/kubernetes-manifests/grafana.yaml b/kubernetes-manifests/grafana.yaml new file mode 100644 index 0000000..16c57e3 --- /dev/null +++ b/kubernetes-manifests/grafana.yaml @@ -0,0 +1,78 @@ +# Copyright 2018 Google LLC +# +# Licensed 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. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: grafana +spec: + template: + metadata: + labels: + app: grafana + spec: + containers: + - name: grafana + image: gcr.io/microservices-demo-app/grafana + ports: + - containerPort: 3000 + readinessProbe: + periodSeconds: 5 + tcpSocket: + port: 3000 + livenessProbe: + periodSeconds: 5 + tcpSocket: + port: 3000 + volumeMounts: + - mountPath: /var/lib/grafana + name: grafana-data + resources: + limits: + memory: 256Mi + cpu: 125m + requests: + cpu: 70m + memory: 200Mi + volumes: + - name: grafana-data + emptyDir: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: grafana +spec: + type: ClusterIP + selector: + app: grafana + ports: + - name: grafana + port: 3000 + targetPort: 3000 +# --- +# TODO (rghetia): Grafana-external is disabled until password issue is resolved. +# +# apiVersion: v1 +# kind: Service +# metadata: +# name: grafana-external +# spec: +# type: LoadBalancer +# selector: +# app: grafana +# ports: +# - name: http +# port: 3000 +# targetPort: 3000 diff --git a/kubernetes-manifests/jaeger.yaml b/kubernetes-manifests/jaeger.yaml new file mode 100644 index 0000000..20e4bb9 --- /dev/null +++ b/kubernetes-manifests/jaeger.yaml @@ -0,0 +1,86 @@ +# Copyright 2018 Google LLC +# +# Licensed 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. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: jaeger +spec: + template: + metadata: + labels: + app: jaeger + spec: + containers: + - name: jaeger + image: gcr.io/microservices-demo-app/jaeger + ports: + - containerPort: 16686 + name: frontend + protocol: TCP + - containerPort: 14268 + name: thrift-direct + protocol: TCP + readinessProbe: + periodSeconds: 5 + tcpSocket: + port: 16686 + livenessProbe: + periodSeconds: 5 + tcpSocket: + port: 16686 + volumeMounts: + - mountPath: /data + name: jaeger-data + resources: + limits: + memory: 256Mi + cpu: 125m + requests: + cpu: 70m + memory: 200Mi + volumes: + - name: jaeger-data + emptyDir: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: jaeger +spec: + type: ClusterIP + selector: + app: jaeger + ports: + - name: frontend + port: 16686 + targetPort: 16686 + protocol: TCP + - name: jaeger-thrift-direct + port: 14268 + targetPort: 14268 + protocol: TCP +--- +apiVersion: v1 +kind: Service +metadata: + name: jaeger-external +spec: + type: LoadBalancer + selector: + app: jaeger + ports: + - name: http + port: 16686 + targetPort: 16686 diff --git a/kubernetes-manifests/prometheus.yaml b/kubernetes-manifests/prometheus.yaml new file mode 100644 index 0000000..03ad55c --- /dev/null +++ b/kubernetes-manifests/prometheus.yaml @@ -0,0 +1,63 @@ +# Copyright 2018 Google LLC +# +# Licensed 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. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: prometheus +spec: + template: + metadata: + labels: + app: prometheus + spec: + containers: + - name: prometheus + image: gcr.io/microservices-demo-app/prometheus + ports: + - containerPort: 9090 + readinessProbe: + periodSeconds: 5 + tcpSocket: + port: 9090 + livenessProbe: + periodSeconds: 5 + tcpSocket: + port: 9090 + volumeMounts: + - mountPath: /data + name: prometheus-data + resources: + limits: + memory: 256Mi + cpu: 125m + requests: + cpu: 70m + memory: 200Mi + volumes: + - name: prometheus-data + emptyDir: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: prometheus +spec: + type: ClusterIP + selector: + app: prometheus + ports: + - name: prometheus + port: 9090 + targetPort: 9090 diff --git a/skaffold.yaml b/skaffold.yaml index b1cd87e..d1a6672 100644 --- a/skaffold.yaml +++ b/skaffold.yaml @@ -38,6 +38,12 @@ build: context: src/loadgenerator - image: gcr.io/microservices-demo-app/adservice context: src/adservice + - image: gcr.io/microservices-demo-app/grafana + context: src/grafana + - image: gcr.io/microservices-demo-app/prometheus + context: src/prometheus + - image: gcr.io/microservices-demo-app/jaeger + context: src/jaeger tagPolicy: gitCommit: {} deploy: diff --git a/src/grafana/Dockerfile b/src/grafana/Dockerfile new file mode 100644 index 0000000..8381b1e --- /dev/null +++ b/src/grafana/Dockerfile @@ -0,0 +1,9 @@ +# adsservice +FROM grafana/grafana +RUN grafana-cli plugins install mtanda-histogram-panel + +COPY provisioning /etc/grafana/provisioning + +WORKDIR / +EXPOSE 3000 +ENTRYPOINT ["/run.sh"] diff --git a/src/grafana/provisioning/dashboards/hipstershop.json b/src/grafana/provisioning/dashboards/hipstershop.json new file mode 100644 index 0000000..0c30a1f --- /dev/null +++ b/src/grafana/provisioning/dashboards/hipstershop.json @@ -0,0 +1,61 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [], + "refresh": false, + "schemaVersion": 16, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Hipstershop Dashboard", + "uid": "FPHI7T0mz", + "version": 1 +} diff --git a/src/grafana/provisioning/dashboards/prometheus.yml b/src/grafana/provisioning/dashboards/prometheus.yml new file mode 100644 index 0000000..fd6f28c --- /dev/null +++ b/src/grafana/provisioning/dashboards/prometheus.yml @@ -0,0 +1,11 @@ +apiVersion: 1 + +providers: +- name: 'prometheus' + orgId: 1 + folder: '' + type: file + disableDeletion: false + updateIntervalSeconds: 3 #how often Grafana will scan for changed dashboards + options: + path: /etc/grafana/provisioning/dashboards/ diff --git a/src/grafana/provisioning/datasources/prometheus.yaml b/src/grafana/provisioning/datasources/prometheus.yaml new file mode 100644 index 0000000..f0f8ddd --- /dev/null +++ b/src/grafana/provisioning/datasources/prometheus.yaml @@ -0,0 +1,18 @@ +# config file version +apiVersion: 1 + +# list of datasources to insert/update depending +# what's available in the database +datasources: + # name of the datasource. Required +- name: Prometheus + # datasource type. Required + type: prometheus + # access mode. proxy or direct (Server or Browser in the UI). Required + access: proxy + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: http://prometheus:9090 + # allow users to edit datasources from the UI. + editable: false diff --git a/src/jaeger/Dockerfile b/src/jaeger/Dockerfile new file mode 100644 index 0000000..d774b87 --- /dev/null +++ b/src/jaeger/Dockerfile @@ -0,0 +1 @@ +FROM jaegertracing/all-in-one:1.6 diff --git a/src/prometheus/Dockerfile b/src/prometheus/Dockerfile new file mode 100644 index 0000000..f2254de --- /dev/null +++ b/src/prometheus/Dockerfile @@ -0,0 +1,3 @@ +# prometheus +FROM prom/prometheus +ADD prometheus.yml /etc/prometheus/ diff --git a/src/prometheus/prometheus.yml b/src/prometheus/prometheus.yml new file mode 100644 index 0000000..96545e1 --- /dev/null +++ b/src/prometheus/prometheus.yml @@ -0,0 +1,41 @@ +# my global config +global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + # scrape_timeout is set to the global default (10s). + +# Alertmanager configuration +alerting: + alertmanagers: + - static_configs: + - targets: + # - alertmanager:9093 + +# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. +rule_files: + # - "first_rules.yml" + # - "second_rules.yml" + +# A scrape configuration containing exactly one endpoint to scrape: +# Here it's Prometheus itself. +scrape_configs: + # The job name is added as a label `job=` to any timeseries scraped from this config. + - job_name: 'prometheus' + + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + + static_configs: + - targets: ['localhost:9090'] + + - job_name: 'adservice' + static_configs: + - targets: ['adservice:9090'] + + - job_name: 'frontend' + static_configs: + - targets: ['frontend:9090'] + + - job_name: 'checkoutservice' + static_configs: + - targets: ['checkoutservice:9090']