├── .gitignore ├── LICENSE ├── README.md ├── ch05 ├── 10 │ ├── mysql-svc.yml │ ├── petclinic-config.yml │ └── petclinic-svc.yml ├── 11 │ ├── mysql-svc.yml │ ├── petclinic-config.yml │ ├── petclinic-secret.yml │ └── petclinic-svc.yml ├── 03 │ └── petclinic-pod.yml ├── 04 │ ├── petclinic-pod.yml │ └── petclinic-service.yml ├── 05 │ ├── petclinic-pod-v1.0.0.yml │ ├── petclinic-pod-v1.0.1.yml │ └── petclinic-service.yml ├── 06 │ ├── peclinic-replicaset.yml │ └── petclinic-service.yml ├── 07 │ ├── petclinic-deployment.yml │ └── petclinic-service.yml └── 08 │ ├── mysql-pod.yml │ ├── mysql-service.yml │ ├── petclinic-deployment.yml │ └── petclinic-service.yml ├── ch07 ├── 01 │ ├── mysql-svc.yml │ └── petclinic-svc.yml ├── 02 │ ├── local-pv.yml │ ├── mysql-pvc.yml │ ├── mysql-svc.yml │ └── petclinic-svc.yml └── 07 │ ├── petclinic-deployment.yml │ └── petclinic-service.yml └── ch08 ├── 10 ├── skywalking-oap.yml └── skywalking-ui.yml ├── 11 ├── .gitignore └── Dockerfile ├── 03 ├── elastic.yml ├── fluentd-daemonset.yml ├── fluentd-rbac.yml ├── kibana.yml └── ns.yml ├── 07 ├── petclinic_msa_dashboard_config.yml ├── values_alertmanager.yml └── values_servicemonitor.yml └── 08 ├── jmeter └── petclinic_test_plan.jmx ├── petclinic_msa_dashboard_config.yml └── values_servicemonitor.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 波波微课 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # k8s-msa-in-action 2 | 课程《Kubernetes微服务实践》源码 3 | -------------------------------------------------------------------------------- /ch05/03/petclinic-pod.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: petclinic 5 | spec: 6 | containers: 7 | - name: petclinic 8 | image: spring2go/spring-petclinic:1.0.0.RELEASE 9 | -------------------------------------------------------------------------------- /ch05/04/petclinic-pod.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: petclinic 5 | labels: 6 | app: petclinic 7 | spec: 8 | containers: 9 | - name: petclinic 10 | image: spring2go/spring-petclinic:1.0.0.RELEASE 11 | -------------------------------------------------------------------------------- /ch05/04/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /ch05/05/petclinic-pod-v1.0.0.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: petclinic-v1.0.0 5 | labels: 6 | app: petclinic 7 | version: v1.0.0 8 | spec: 9 | containers: 10 | - name: petclinic 11 | image: spring2go/spring-petclinic:1.0.0.RELEASE 12 | -------------------------------------------------------------------------------- /ch05/05/petclinic-pod-v1.0.1.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: petclinic-v1.0.1 5 | labels: 6 | app: petclinic 7 | version: v1.0.1 8 | spec: 9 | containers: 10 | - name: petclinic 11 | image: spring2go/spring-petclinic:1.0.1.RELEASE 12 | -------------------------------------------------------------------------------- /ch05/05/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | version: v1.0.1 14 | type: NodePort 15 | -------------------------------------------------------------------------------- /ch05/06/peclinic-replicaset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: extensions/v1beta1 2 | kind: ReplicaSet 3 | metadata: 4 | name: petclinic 5 | spec: 6 | replicas: 3 7 | template: 8 | metadata: 9 | labels: 10 | app: petclinic 11 | spec: 12 | containers: 13 | - name: petclinic 14 | image: spring2go/spring-petclinic:1.0.0.RELEASE 15 | -------------------------------------------------------------------------------- /ch05/06/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /ch05/07/petclinic-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | minReadySeconds: 10 10 | replicas: 3 11 | template: 12 | metadata: 13 | labels: 14 | app: petclinic 15 | spec: 16 | containers: 17 | - name: petclinic 18 | image: spring2go/spring-petclinic:1.0.1.RELEASE 19 | -------------------------------------------------------------------------------- /ch05/07/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /ch05/08/mysql-pod.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: mysql 5 | labels: 6 | app: mysql 7 | spec: 8 | containers: 9 | - name: mysql 10 | image: mysql:5.7 11 | env: 12 | - name: MYSQL_ROOT_PASSWORD 13 | value: petclinic 14 | - name: MYSQL_DATABASE 15 | value: petclinic 16 | -------------------------------------------------------------------------------- /ch05/08/mysql-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mysql 5 | spec: 6 | selector: 7 | app: mysql 8 | ports: 9 | - name: tcp 10 | port: 3306 11 | targetPort: 3306 12 | type: ClusterIP 13 | -------------------------------------------------------------------------------- /ch05/08/petclinic-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: petclinic 14 | spec: 15 | containers: 16 | - name: petclinic 17 | image: spring2go/spring-petclinic:1.0.1.RELEASE 18 | env: 19 | - name: SPRING_PROFILES_ACTIVE 20 | value: mysql 21 | - name: DATASOURCE_URL 22 | value: jdbc:mysql://mysql/petclinic 23 | - name: DATASOURCE_USERNAME 24 | value: root 25 | - name: DATASOURCE_PASSWORD 26 | value: petclinic 27 | - name: DATASOURCE_INIT_MODE 28 | value: always 29 | -------------------------------------------------------------------------------- /ch05/08/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /ch05/10/mysql-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: mysql 5 | labels: 6 | app: mysql 7 | spec: 8 | containers: 9 | - name: mysql 10 | image: mysql:5.7 11 | env: 12 | - name: MYSQL_ROOT_PASSWORD 13 | value: petclinic 14 | - name: MYSQL_DATABASE 15 | value: petclinic 16 | --- 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: mysql 21 | spec: 22 | selector: 23 | app: mysql 24 | ports: 25 | - name: tcp 26 | port: 3306 27 | targetPort: 3306 28 | type: ClusterIP 29 | -------------------------------------------------------------------------------- /ch05/10/petclinic-config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: petclinic-config-v2 5 | data: 6 | SPRING_PROFILES_ACTIVE: mysql 7 | DATASOURCE_URL: jdbc:mysql://mysql/petclinic 8 | DATASOURCE_USERNAME: root 9 | DATASOURCE_PASSWORD: petclinic 10 | DATASOURCE_INIT_MODE: always 11 | TEST_CONFIG: test_config_v2 12 | -------------------------------------------------------------------------------- /ch05/10/petclinic-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: petclinic 14 | spec: 15 | containers: 16 | - name: petclinic 17 | image: spring2go/spring-petclinic:1.0.1.RELEASE 18 | envFrom: 19 | - configMapRef: 20 | name: petclinic-config-v2 21 | --- 22 | apiVersion: v1 23 | kind: Service 24 | metadata: 25 | name: petclinic 26 | spec: 27 | ports: 28 | - name: http 29 | port: 8080 30 | targetPort: 8080 31 | nodePort: 31080 32 | selector: 33 | app: petclinic 34 | type: NodePort 35 | -------------------------------------------------------------------------------- /ch05/11/mysql-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: mysql 5 | labels: 6 | app: mysql 7 | spec: 8 | containers: 9 | - name: mysql 10 | image: mysql:5.7 11 | env: 12 | - name: MYSQL_ROOT_PASSWORD 13 | value: petclinic 14 | - name: MYSQL_DATABASE 15 | value: petclinic 16 | --- 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: mysql 21 | spec: 22 | selector: 23 | app: mysql 24 | ports: 25 | - name: tcp 26 | port: 3306 27 | targetPort: 3306 28 | type: ClusterIP 29 | -------------------------------------------------------------------------------- /ch05/11/petclinic-config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: petclinic-config-v2 5 | data: 6 | SPRING_PROFILES_ACTIVE: mysql 7 | DATASOURCE_URL: jdbc:mysql://mysql/petclinic 8 | DATASOURCE_INIT_MODE: always 9 | TEST_CONFIG: test_config_v2 10 | -------------------------------------------------------------------------------- /ch05/11/petclinic-secret.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: petclinic-secret 5 | type: Opaque 6 | stringData: 7 | DATASOURCE_USERNAME: root 8 | DATASOURCE_PASSWORD: petclinic 9 | -------------------------------------------------------------------------------- /ch05/11/petclinic-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: petclinic 14 | spec: 15 | containers: 16 | - name: petclinic 17 | image: spring2go/spring-petclinic:1.0.1.RELEASE 18 | envFrom: 19 | - configMapRef: 20 | name: petclinic-config-v2 21 | - secretRef: 22 | name: petclinic-secret 23 | --- 24 | apiVersion: v1 25 | kind: Service 26 | metadata: 27 | name: petclinic 28 | spec: 29 | ports: 30 | - name: http 31 | port: 8080 32 | targetPort: 8080 33 | nodePort: 31080 34 | selector: 35 | app: petclinic 36 | type: NodePort 37 | -------------------------------------------------------------------------------- /ch07/01/mysql-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: mysql 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: mysql 14 | spec: 15 | containers: 16 | - name: mysql 17 | image: mysql:5.7 18 | env: 19 | - name: MYSQL_ROOT_PASSWORD 20 | value: petclinic 21 | - name: MYSQL_DATABASE 22 | value: petclinic 23 | volumeMounts: 24 | - name: mysql-persistent-volume 25 | mountPath: /var/lib/mysql 26 | volumes: 27 | - name: mysql-persistent-volume 28 | hostPath: 29 | path: /tmp/data01 30 | type: DirectoryOrCreate 31 | --- 32 | apiVersion: v1 33 | kind: Service 34 | metadata: 35 | name: mysql 36 | spec: 37 | selector: 38 | app: mysql 39 | ports: 40 | - name: tcp 41 | port: 3306 42 | targetPort: 3306 43 | type: ClusterIP 44 | -------------------------------------------------------------------------------- /ch07/01/petclinic-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: petclinic 14 | spec: 15 | containers: 16 | - name: petclinic 17 | image: spring2go/spring-petclinic:1.0.1.RELEASE 18 | env: 19 | - name: SPRING_PROFILES_ACTIVE 20 | value: mysql 21 | - name: DATASOURCE_URL 22 | value: jdbc:mysql://mysql/petclinic 23 | - name: DATASOURCE_USERNAME 24 | value: root 25 | - name: DATASOURCE_PASSWORD 26 | value: petclinic 27 | - name: DATASOURCE_INIT_MODE 28 | value: always 29 | 30 | --- 31 | apiVersion: v1 32 | kind: Service 33 | metadata: 34 | name: petclinic 35 | spec: 36 | ports: 37 | - name: http 38 | port: 8080 39 | targetPort: 8080 40 | nodePort: 31080 41 | selector: 42 | app: petclinic 43 | type: NodePort 44 | -------------------------------------------------------------------------------- /ch07/02/local-pv.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolume 3 | metadata: 4 | name: local-pv 5 | spec: 6 | storageClassName: standard 7 | capacity: 8 | storage: 250Mi 9 | accessModes: 10 | - ReadWriteOnce 11 | hostPath: 12 | path: "/tmp/data02" 13 | type: DirectoryOrCreate 14 | -------------------------------------------------------------------------------- /ch07/02/mysql-pvc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: mysql-pvc 5 | spec: 6 | storageClassName: standard 7 | accessModes: 8 | - ReadWriteOnce 9 | resources: 10 | requests: 11 | storage: 250Mi 12 | -------------------------------------------------------------------------------- /ch07/02/mysql-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mysql 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: mysql 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: mysql 14 | spec: 15 | containers: 16 | - name: mysql 17 | image: mysql:5.7 18 | env: 19 | - name: MYSQL_ROOT_PASSWORD 20 | value: petclinic 21 | - name: MYSQL_DATABASE 22 | value: petclinic 23 | volumeMounts: 24 | - name: mysql-persistent-volume 25 | mountPath: /var/lib/mysql 26 | volumes: 27 | - name: mysql-persistent-volume 28 | persistentVolumeClaim: 29 | claimName: mysql-pvc 30 | 31 | --- 32 | apiVersion: v1 33 | kind: Service 34 | metadata: 35 | name: mysql 36 | spec: 37 | selector: 38 | app: mysql 39 | ports: 40 | - name: tcp 41 | port: 3306 42 | targetPort: 3306 43 | type: ClusterIP 44 | -------------------------------------------------------------------------------- /ch07/02/petclinic-svc.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | replicas: 1 10 | template: 11 | metadata: 12 | labels: 13 | app: petclinic 14 | spec: 15 | containers: 16 | - name: petclinic 17 | image: spring2go/spring-petclinic:1.0.1.RELEASE 18 | env: 19 | - name: SPRING_PROFILES_ACTIVE 20 | value: mysql 21 | - name: DATASOURCE_URL 22 | value: jdbc:mysql://mysql/petclinic 23 | - name: DATASOURCE_USERNAME 24 | value: root 25 | - name: DATASOURCE_PASSWORD 26 | value: petclinic 27 | - name: DATASOURCE_INIT_MODE 28 | value: always 29 | --- 30 | apiVersion: v1 31 | kind: Service 32 | metadata: 33 | name: petclinic 34 | spec: 35 | ports: 36 | - name: http 37 | port: 8080 38 | targetPort: 8080 39 | nodePort: 31080 40 | selector: 41 | app: petclinic 42 | type: NodePort 43 | -------------------------------------------------------------------------------- /ch07/07/petclinic-deployment.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: petclinic 5 | spec: 6 | selector: 7 | matchLabels: 8 | app: petclinic 9 | minReadySeconds: 10 10 | replicas: 3 11 | template: 12 | metadata: 13 | labels: 14 | app: petclinic 15 | spec: 16 | containers: 17 | - name: petclinic 18 | image: spring2go/spring-petclinic:1.0.1.RELEASE 19 | -------------------------------------------------------------------------------- /ch07/07/petclinic-service.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: petclinic 5 | spec: 6 | ports: 7 | - name: http 8 | port: 8080 9 | targetPort: 8080 10 | nodePort: 31080 11 | selector: 12 | app: petclinic 13 | type: NodePort 14 | -------------------------------------------------------------------------------- /ch08/03/elastic.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: elasticsearch 5 | namespace: logging 6 | spec: 7 | selector: 8 | matchLabels: 9 | component: elasticsearch 10 | template: 11 | metadata: 12 | labels: 13 | component: elasticsearch 14 | spec: 15 | containers: 16 | - name: elasticsearch 17 | image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4 18 | env: 19 | - name: discovery.type 20 | value: single-node 21 | ports: 22 | - containerPort: 9200 23 | name: http 24 | protocol: TCP 25 | resources: 26 | limits: 27 | cpu: 500m 28 | memory: 2Gi 29 | requests: 30 | cpu: 500m 31 | memory: 2Gi 32 | --- 33 | apiVersion: v1 34 | kind: Service 35 | metadata: 36 | name: elasticsearch 37 | namespace: logging 38 | labels: 39 | service: elasticsearch 40 | spec: 41 | type: NodePort 42 | selector: 43 | component: elasticsearch 44 | ports: 45 | - port: 9200 46 | targetPort: 9200 47 | nodePort: 31200 48 | -------------------------------------------------------------------------------- /ch08/03/fluentd-daemonset.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: DaemonSet 3 | metadata: 4 | name: fluentd 5 | namespace: kube-system 6 | labels: 7 | k8s-app: fluentd-logging 8 | version: v1 9 | kubernetes.io/cluster-service: "true" 10 | spec: 11 | selector: 12 | matchLabels: 13 | k8s-app: fluentd-logging 14 | version: v1 15 | template: 16 | metadata: 17 | labels: 18 | k8s-app: fluentd-logging 19 | version: v1 20 | kubernetes.io/cluster-service: "true" 21 | spec: 22 | serviceAccount: fluentd 23 | serviceAccountName: fluentd 24 | tolerations: 25 | - key: node-role.kubernetes.io/master 26 | effect: NoSchedule 27 | containers: 28 | - name: fluentd 29 | image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch 30 | env: 31 | - name: FLUENT_ELASTICSEARCH_HOST 32 | value: "elasticsearch.logging" 33 | - name: FLUENT_ELASTICSEARCH_PORT 34 | value: "9200" 35 | - name: FLUENT_ELASTICSEARCH_SCHEME 36 | value: "http" 37 | - name: FLUENT_UID 38 | value: "0" 39 | - name: FLUENTD_SYSTEMD_CONF 40 | value: disable 41 | resources: 42 | limits: 43 | memory: 200Mi 44 | requests: 45 | cpu: 100m 46 | memory: 200Mi 47 | volumeMounts: 48 | - name: varlog 49 | mountPath: /var/log 50 | - name: varlibdockercontainers 51 | mountPath: /var/lib/docker/containers 52 | readOnly: true 53 | terminationGracePeriodSeconds: 30 54 | volumes: 55 | - name: varlog 56 | hostPath: 57 | path: /var/log 58 | - name: varlibdockercontainers 59 | hostPath: 60 | path: /var/lib/docker/containers 61 | -------------------------------------------------------------------------------- /ch08/03/fluentd-rbac.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: fluentd 5 | namespace: kube-system 6 | --- 7 | apiVersion: rbac.authorization.k8s.io/v1beta1 8 | kind: ClusterRole 9 | metadata: 10 | name: fluentd 11 | namespace: kube-system 12 | rules: 13 | - apiGroups: 14 | - "" 15 | resources: 16 | - pods 17 | - namespaces 18 | verbs: 19 | - get 20 | - list 21 | - watch 22 | --- 23 | kind: ClusterRoleBinding 24 | apiVersion: rbac.authorization.k8s.io/v1beta1 25 | metadata: 26 | name: fluentd 27 | roleRef: 28 | kind: ClusterRole 29 | name: fluentd 30 | apiGroup: rbac.authorization.k8s.io 31 | subjects: 32 | - kind: ServiceAccount 33 | name: fluentd 34 | namespace: kube-system 35 | -------------------------------------------------------------------------------- /ch08/03/kibana.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: kibana 5 | namespace: logging 6 | spec: 7 | selector: 8 | matchLabels: 9 | run: kibana 10 | template: 11 | metadata: 12 | labels: 13 | run: kibana 14 | spec: 15 | containers: 16 | - name: kibana 17 | image: docker.elastic.co/kibana/kibana:6.5.4 18 | env: 19 | - name: ELASTICSEARCH_URL 20 | value: http://elasticsearch:9200 21 | - name: XPACK_SECURITY_ENABLED 22 | value: "true" 23 | ports: 24 | - containerPort: 5601 25 | name: http 26 | protocol: TCP 27 | --- 28 | apiVersion: v1 29 | kind: Service 30 | metadata: 31 | name: kibana 32 | namespace: logging 33 | labels: 34 | service: kibana 35 | spec: 36 | type: NodePort 37 | selector: 38 | run: kibana 39 | ports: 40 | - port: 5601 41 | targetPort: 5601 42 | nodePort: 31601 43 | -------------------------------------------------------------------------------- /ch08/03/ns.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: logging 5 | -------------------------------------------------------------------------------- /ch08/07/petclinic_msa_dashboard_config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: petclinic-msa-dashboard 5 | namespace: monitoring 6 | labels: 7 | grafana_dashboard: "1" 8 | data: 9 | petclinic-msa-dashboard.json: | 10 | { 11 | "__requires": [], 12 | "annotations": { 13 | "list": [ 14 | { 15 | "builtIn": 1, 16 | "datasource": "-- Grafana --", 17 | "enable": true, 18 | "hide": true, 19 | "iconColor": "rgba(0, 211, 255, 1)", 20 | "name": "Annotations & Alerts", 21 | "type": "dashboard" 22 | } 23 | ] 24 | }, 25 | "editable": true, 26 | "gnetId": null, 27 | "graphTooltip": 0, 28 | "id": null, 29 | "iteration": 1539967676482, 30 | "links": [], 31 | "panels": [ 32 | { 33 | "aliasColors": {}, 34 | "bars": false, 35 | "dashLength": 10, 36 | "dashes": false, 37 | "datasource": "Prometheus", 38 | "fill": 1, 39 | "gridPos": { 40 | "h": 9, 41 | "w": 12, 42 | "x": 0, 43 | "y": 0 44 | }, 45 | "id": 11, 46 | "legend": { 47 | "avg": false, 48 | "current": true, 49 | "max": false, 50 | "min": false, 51 | "show": true, 52 | "total": false, 53 | "values": true 54 | }, 55 | "lines": true, 56 | "linewidth": 1, 57 | "links": [], 58 | "nullPointMode": "null", 59 | "percentage": false, 60 | "pointradius": 5, 61 | "points": false, 62 | "renderer": "flot", 63 | "seriesOverrides": [], 64 | "spaceLength": 10, 65 | "stack": false, 66 | "steppedLine": false, 67 | "targets": [ 68 | { 69 | "expr": "sum(rate(http_server_requests_seconds_sum{status!~\"5..\"}[1m]))/sum(rate(http_server_requests_seconds_count{ status!~\"5..\"}[1m]))", 70 | "format": "time_series", 71 | "intervalFactor": 1, 72 | "legendFormat": "HTTP - AVG", 73 | "refId": "A" 74 | }, 75 | { 76 | "expr": "max(http_server_requests_seconds_max{status!~\"5..\"})", 77 | "format": "time_series", 78 | "intervalFactor": 1, 79 | "legendFormat": "HTTP - MAX", 80 | "refId": "B" 81 | } 82 | ], 83 | "thresholds": [], 84 | "timeFrom": null, 85 | "timeShift": null, 86 | "title": "HTTP Request Latency", 87 | "tooltip": { 88 | "shared": true, 89 | "sort": 0, 90 | "value_type": "individual" 91 | }, 92 | "type": "graph", 93 | "xaxis": { 94 | "buckets": null, 95 | "mode": "time", 96 | "name": null, 97 | "show": true, 98 | "values": [] 99 | }, 100 | "yaxes": [ 101 | { 102 | "decimals": null, 103 | "format": "s", 104 | "label": null, 105 | "logBase": 1, 106 | "max": null, 107 | "min": "0", 108 | "show": true 109 | }, 110 | { 111 | "format": "short", 112 | "label": null, 113 | "logBase": 1, 114 | "max": null, 115 | "min": null, 116 | "show": true 117 | } 118 | ] 119 | }, 120 | { 121 | "aliasColors": {}, 122 | "bars": false, 123 | "dashLength": 10, 124 | "dashes": false, 125 | "datasource": "Prometheus", 126 | "fill": 1, 127 | "gridPos": { 128 | "h": 9, 129 | "w": 12, 130 | "x": 12, 131 | "y": 0 132 | }, 133 | "id": 9, 134 | "legend": { 135 | "avg": false, 136 | "current": true, 137 | "max": true, 138 | "min": false, 139 | "show": true, 140 | "total": false, 141 | "values": true 142 | }, 143 | "lines": true, 144 | "linewidth": 1, 145 | "links": [], 146 | "nullPointMode": "null", 147 | "percentage": false, 148 | "pointradius": 0.5, 149 | "points": true, 150 | "renderer": "flot", 151 | "seriesOverrides": [], 152 | "spaceLength": 10, 153 | "stack": false, 154 | "steppedLine": false, 155 | "targets": [ 156 | { 157 | "expr": "sum(rate(http_server_requests_seconds_count[1m]))", 158 | "format": "time_series", 159 | "interval": "", 160 | "intervalFactor": 1, 161 | "legendFormat": "request - ok", 162 | "refId": "A" 163 | }, 164 | { 165 | "expr": "sum(rate(http_server_requests_seconds_count{status=~\"5..\"}[1m]))", 166 | "format": "time_series", 167 | "interval": "", 168 | "intervalFactor": 1, 169 | "legendFormat": "request - err", 170 | "refId": "B" 171 | } 172 | ], 173 | "thresholds": [], 174 | "timeFrom": null, 175 | "timeShift": null, 176 | "title": "HTTP Request Activity", 177 | "tooltip": { 178 | "shared": true, 179 | "sort": 0, 180 | "value_type": "individual" 181 | }, 182 | "type": "graph", 183 | "xaxis": { 184 | "buckets": null, 185 | "mode": "time", 186 | "name": null, 187 | "show": true, 188 | "values": [] 189 | }, 190 | "yaxes": [ 191 | { 192 | "format": "ops", 193 | "label": null, 194 | "logBase": 1, 195 | "max": null, 196 | "min": "0", 197 | "show": true 198 | }, 199 | { 200 | "format": "short", 201 | "label": null, 202 | "logBase": 1, 203 | "max": null, 204 | "min": null, 205 | "show": true 206 | } 207 | ] 208 | }, 209 | { 210 | "cacheTimeout": null, 211 | "colorBackground": false, 212 | "colorValue": false, 213 | "colors": [ 214 | "#299c46", 215 | "rgba(237, 129, 40, 0.89)", 216 | "#d44a3a" 217 | ], 218 | "datasource": "Prometheus", 219 | "format": "none", 220 | "gauge": { 221 | "maxValue": 100, 222 | "minValue": 0, 223 | "show": false, 224 | "thresholdLabels": false, 225 | "thresholdMarkers": true 226 | }, 227 | "gridPos": { 228 | "h": 5, 229 | "w": 6, 230 | "x": 0, 231 | "y": 9 232 | }, 233 | "id": 2, 234 | "interval": null, 235 | "links": [], 236 | "mappingType": 1, 237 | "mappingTypes": [ 238 | { 239 | "name": "value to text", 240 | "value": 1 241 | }, 242 | { 243 | "name": "range to text", 244 | "value": 2 245 | } 246 | ], 247 | "maxDataPoints": 100, 248 | "nullPointMode": "connected", 249 | "nullText": null, 250 | "postfix": "", 251 | "postfixFontSize": "50%", 252 | "prefix": "", 253 | "prefixFontSize": "50%", 254 | "rangeMaps": [ 255 | { 256 | "from": "null", 257 | "text": "N/A", 258 | "to": "null" 259 | } 260 | ], 261 | "sparkline": { 262 | "fillColor": "rgba(31, 118, 189, 0.18)", 263 | "full": false, 264 | "lineColor": "rgb(31, 120, 193)", 265 | "show": false 266 | }, 267 | "tableColumn": "", 268 | "targets": [ 269 | { 270 | "expr": "sum(petclinic_owner_seconds_count{method=\"PUT\", status=\"204\"})", 271 | "format": "time_series", 272 | "instant": true, 273 | "intervalFactor": 1, 274 | "refId": "A" 275 | } 276 | ], 277 | "thresholds": "", 278 | "title": "Owners Updated", 279 | "type": "singlestat", 280 | "valueFontSize": "80%", 281 | "valueMaps": [ 282 | { 283 | "op": "=", 284 | "text": "N/A", 285 | "value": "null" 286 | } 287 | ], 288 | "valueName": "avg" 289 | }, 290 | { 291 | "cacheTimeout": null, 292 | "colorBackground": false, 293 | "colorValue": false, 294 | "colors": [ 295 | "#299c46", 296 | "rgba(237, 129, 40, 0.89)", 297 | "#d44a3a" 298 | ], 299 | "datasource": "Prometheus", 300 | "format": "none", 301 | "gauge": { 302 | "maxValue": 100, 303 | "minValue": 0, 304 | "show": false, 305 | "thresholdLabels": false, 306 | "thresholdMarkers": true 307 | }, 308 | "gridPos": { 309 | "h": 5, 310 | "w": 6, 311 | "x": 6, 312 | "y": 9 313 | }, 314 | "id": 3, 315 | "interval": null, 316 | "links": [], 317 | "mappingType": 1, 318 | "mappingTypes": [ 319 | { 320 | "name": "value to text", 321 | "value": 1 322 | }, 323 | { 324 | "name": "range to text", 325 | "value": 2 326 | } 327 | ], 328 | "maxDataPoints": 100, 329 | "nullPointMode": "connected", 330 | "nullText": null, 331 | "postfix": "", 332 | "postfixFontSize": "50%", 333 | "prefix": "", 334 | "prefixFontSize": "50%", 335 | "rangeMaps": [ 336 | { 337 | "from": "null", 338 | "text": "N/A", 339 | "to": "null" 340 | } 341 | ], 342 | "sparkline": { 343 | "fillColor": "rgba(31, 118, 189, 0.18)", 344 | "full": false, 345 | "lineColor": "rgb(31, 120, 193)", 346 | "show": false 347 | }, 348 | "tableColumn": "", 349 | "targets": [ 350 | { 351 | "expr": "sum(petclinic_owner_seconds_count{method=\"POST\", status=\"201\"})", 352 | "format": "time_series", 353 | "instant": true, 354 | "intervalFactor": 1, 355 | "legendFormat": "", 356 | "refId": "A" 357 | } 358 | ], 359 | "thresholds": "", 360 | "title": "Owners Created", 361 | "type": "singlestat", 362 | "valueFontSize": "80%", 363 | "valueMaps": [ 364 | { 365 | "op": "=", 366 | "text": "N/A", 367 | "value": "null" 368 | } 369 | ], 370 | "valueName": "avg" 371 | }, 372 | { 373 | "cacheTimeout": null, 374 | "colorBackground": false, 375 | "colorValue": false, 376 | "colors": [ 377 | "#299c46", 378 | "rgba(237, 129, 40, 0.89)", 379 | "#d44a3a" 380 | ], 381 | "datasource": "Prometheus", 382 | "format": "none", 383 | "gauge": { 384 | "maxValue": 100, 385 | "minValue": 0, 386 | "show": false, 387 | "thresholdLabels": false, 388 | "thresholdMarkers": true 389 | }, 390 | "gridPos": { 391 | "h": 5, 392 | "w": 6, 393 | "x": 12, 394 | "y": 9 395 | }, 396 | "id": 4, 397 | "interval": null, 398 | "links": [], 399 | "mappingType": 1, 400 | "mappingTypes": [ 401 | { 402 | "name": "value to text", 403 | "value": 1 404 | }, 405 | { 406 | "name": "range to text", 407 | "value": 2 408 | } 409 | ], 410 | "maxDataPoints": 100, 411 | "nullPointMode": "connected", 412 | "nullText": null, 413 | "postfix": "", 414 | "postfixFontSize": "50%", 415 | "prefix": "", 416 | "prefixFontSize": "50%", 417 | "rangeMaps": [ 418 | { 419 | "from": "null", 420 | "text": "N/A", 421 | "to": "null" 422 | } 423 | ], 424 | "sparkline": { 425 | "fillColor": "rgba(31, 118, 189, 0.18)", 426 | "full": false, 427 | "lineColor": "rgb(31, 120, 193)", 428 | "show": false 429 | }, 430 | "tableColumn": "", 431 | "targets": [ 432 | { 433 | "expr": "sum(petclinic_pet_seconds_count{method=\"POST\", status=\"201\"})", 434 | "format": "time_series", 435 | "instant": true, 436 | "intervalFactor": 1, 437 | "legendFormat": "", 438 | "refId": "A" 439 | } 440 | ], 441 | "thresholds": "", 442 | "title": "Pets Created", 443 | "type": "singlestat", 444 | "valueFontSize": "80%", 445 | "valueMaps": [ 446 | { 447 | "op": "=", 448 | "text": "N/A", 449 | "value": "null" 450 | } 451 | ], 452 | "valueName": "avg" 453 | }, 454 | { 455 | "cacheTimeout": null, 456 | "colorBackground": false, 457 | "colorValue": false, 458 | "colors": [ 459 | "#299c46", 460 | "rgba(237, 129, 40, 0.89)", 461 | "#d44a3a" 462 | ], 463 | "datasource": "Prometheus", 464 | "format": "none", 465 | "gauge": { 466 | "maxValue": 100, 467 | "minValue": 0, 468 | "show": false, 469 | "thresholdLabels": false, 470 | "thresholdMarkers": true 471 | }, 472 | "gridPos": { 473 | "h": 5, 474 | "w": 6, 475 | "x": 18, 476 | "y": 9 477 | }, 478 | "id": 5, 479 | "interval": null, 480 | "links": [], 481 | "mappingType": 1, 482 | "mappingTypes": [ 483 | { 484 | "name": "value to text", 485 | "value": 1 486 | }, 487 | { 488 | "name": "range to text", 489 | "value": 2 490 | } 491 | ], 492 | "maxDataPoints": 100, 493 | "nullPointMode": "connected", 494 | "nullText": null, 495 | "postfix": "", 496 | "postfixFontSize": "50%", 497 | "prefix": "", 498 | "prefixFontSize": "50%", 499 | "rangeMaps": [ 500 | { 501 | "from": "null", 502 | "text": "N/A", 503 | "to": "null" 504 | } 505 | ], 506 | "sparkline": { 507 | "fillColor": "rgba(31, 118, 189, 0.18)", 508 | "full": false, 509 | "lineColor": "rgb(31, 120, 193)", 510 | "show": false 511 | }, 512 | "tableColumn": "Value", 513 | "targets": [ 514 | { 515 | "expr": "sum(petclinic_visit_seconds_count{method=\"POST\", status=\"201\"})", 516 | "format": "time_series", 517 | "instant": true, 518 | "intervalFactor": 1, 519 | "legendFormat": "", 520 | "refId": "A" 521 | } 522 | ], 523 | "thresholds": "", 524 | "title": "Visit Created", 525 | "type": "singlestat", 526 | "valueFontSize": "80%", 527 | "valueMaps": [ 528 | { 529 | "op": "=", 530 | "text": "N/A", 531 | "value": "null" 532 | } 533 | ], 534 | "valueName": "avg" 535 | }, 536 | { 537 | "aliasColors": {}, 538 | "bars": true, 539 | "dashLength": 10, 540 | "dashes": false, 541 | "datasource": "Prometheus", 542 | "fill": 1, 543 | "gridPos": { 544 | "h": 8, 545 | "w": 24, 546 | "x": 0, 547 | "y": 14 548 | }, 549 | "id": 7, 550 | "legend": { 551 | "alignAsTable": false, 552 | "avg": false, 553 | "current": false, 554 | "hideEmpty": false, 555 | "hideZero": true, 556 | "max": true, 557 | "min": false, 558 | "rightSide": false, 559 | "show": true, 560 | "total": false, 561 | "values": true 562 | }, 563 | "lines": false, 564 | "linewidth": 1, 565 | "links": [], 566 | "nullPointMode": "null", 567 | "percentage": false, 568 | "pointradius": 5, 569 | "points": false, 570 | "renderer": "flot", 571 | "seriesOverrides": [], 572 | "spaceLength": 10, 573 | "stack": true, 574 | "steppedLine": false, 575 | "targets": [ 576 | { 577 | "expr": "sum(petclinic_owner_seconds_count{method=\"POST\", status=\"201\"})", 578 | "format": "time_series", 579 | "instant": false, 580 | "intervalFactor": 1, 581 | "legendFormat": "owner create", 582 | "refId": "A" 583 | }, 584 | { 585 | "expr": "sum(petclinic_pet_seconds_count{method=\"POST\", status=\"201\"})", 586 | "format": "time_series", 587 | "intervalFactor": 1, 588 | "legendFormat": "pet create", 589 | "refId": "B" 590 | }, 591 | { 592 | "expr": "sum(petclinic_visit_seconds_count{method=\"POST\", status=\"201\"})", 593 | "format": "time_series", 594 | "intervalFactor": 1, 595 | "legendFormat": "visit create", 596 | "refId": "C" 597 | }, 598 | { 599 | "expr": "sum(petclinic_owner_seconds_count{method=\"PUT\", status=\"204\"})", 600 | "format": "time_series", 601 | "intervalFactor": 1, 602 | "legendFormat": "owner update", 603 | "refId": "D" 604 | } 605 | ], 606 | "thresholds": [], 607 | "timeFrom": null, 608 | "timeShift": null, 609 | "title": "SPC Business Histogram", 610 | "tooltip": { 611 | "shared": true, 612 | "sort": 0, 613 | "value_type": "individual" 614 | }, 615 | "type": "graph", 616 | "xaxis": { 617 | "buckets": null, 618 | "mode": "time", 619 | "name": null, 620 | "show": true, 621 | "values": [] 622 | }, 623 | "yaxes": [ 624 | { 625 | "format": "short", 626 | "label": null, 627 | "logBase": 1, 628 | "max": null, 629 | "min": null, 630 | "show": true 631 | }, 632 | { 633 | "format": "short", 634 | "label": null, 635 | "logBase": 1, 636 | "max": null, 637 | "min": null, 638 | "show": true 639 | } 640 | ] 641 | } 642 | ], 643 | "refresh": "30s", 644 | "schemaVersion": 16, 645 | "style": "dark", 646 | "tags": [], 647 | "templating": { 648 | "list": [ 649 | { 650 | "auto": true, 651 | "auto_count": 1, 652 | "auto_min": "10s", 653 | "current": { 654 | "text": "auto", 655 | "value": "$__auto_interval_timeRange" 656 | }, 657 | "hide": 0, 658 | "label": null, 659 | "name": "timeRange", 660 | "options": [ 661 | { 662 | "selected": true, 663 | "text": "auto", 664 | "value": "$__auto_interval_timeRange" 665 | }, 666 | { 667 | "selected": false, 668 | "text": "1m", 669 | "value": "1m" 670 | }, 671 | { 672 | "selected": false, 673 | "text": "10m", 674 | "value": "10m" 675 | }, 676 | { 677 | "selected": false, 678 | "text": "30m", 679 | "value": "30m" 680 | }, 681 | { 682 | "selected": false, 683 | "text": "1h", 684 | "value": "1h" 685 | }, 686 | { 687 | "selected": false, 688 | "text": "6h", 689 | "value": "6h" 690 | }, 691 | { 692 | "selected": false, 693 | "text": "12h", 694 | "value": "12h" 695 | }, 696 | { 697 | "selected": false, 698 | "text": "1d", 699 | "value": "1d" 700 | }, 701 | { 702 | "selected": false, 703 | "text": "7d", 704 | "value": "7d" 705 | }, 706 | { 707 | "selected": false, 708 | "text": "14d", 709 | "value": "14d" 710 | }, 711 | { 712 | "selected": false, 713 | "text": "30d", 714 | "value": "30d" 715 | } 716 | ], 717 | "query": "1m,10m,30m,1h,6h,12h,1d,7d,14d,30d", 718 | "refresh": 2, 719 | "type": "interval" 720 | } 721 | ] 722 | }, 723 | "time": { 724 | "from": "now-1h", 725 | "to": "now" 726 | }, 727 | "timepicker": { 728 | "refresh_intervals": [ 729 | "5s", 730 | "10s", 731 | "30s", 732 | "1m", 733 | "5m", 734 | "15m", 735 | "30m", 736 | "1h", 737 | "2h", 738 | "1d" 739 | ], 740 | "time_options": [ 741 | "5m", 742 | "15m", 743 | "1h", 744 | "6h", 745 | "12h", 746 | "24h", 747 | "2d", 748 | "7d", 749 | "30d" 750 | ] 751 | }, 752 | "timezone": "", 753 | "title": "Spring Petclinic Metrics", 754 | "uid": "69JXeR0iw", 755 | "version": 1 756 | } 757 | -------------------------------------------------------------------------------- /ch08/07/values_alertmanager.yml: -------------------------------------------------------------------------------- 1 | # Configuration for alertmanager 2 | alertmanager: 3 | config: 4 | global: 5 | smtp_from: alertmanager@gmail.com 6 | smtp_require_tls: false 7 | smtp_smarthost: 192.168.0.100:2525 8 | resolve_timeout: 5m 9 | route: 10 | group_by: ["job"] 11 | group_wait: 30s 12 | group_interval: 5m 13 | repeat_interval: 12h 14 | receiver: "fake_email" 15 | routes: 16 | - match: 17 | alertname: Watchdog 18 | receiver: "null" 19 | #This inhibit rule is a hack from: https://stackoverflow.com/questions/54806336/how-to-silence-prometheus-alertmanager-using-config-files/54814033#54814033 20 | inhibit_rules: 21 | - target_match_re: 22 | alertname: ".+Overcommit" 23 | source_match: 24 | alertname: "Watchdog" 25 | equal: ["prometheus"] 26 | receivers: 27 | - name: "null" 28 | - name: "fake_email" 29 | email_configs: 30 | - send_resolved: true 31 | to: me@gmail.com 32 | -------------------------------------------------------------------------------- /ch08/07/values_servicemonitor.yml: -------------------------------------------------------------------------------- 1 | prometheus: 2 | additionalServiceMonitors: 3 | - name: "petclinic-gateway" 4 | selector: 5 | matchLabels: 6 | svc: gateway 7 | namespaceSelector: 8 | matchNames: 9 | - default 10 | endpoints: 11 | - port: http 12 | path: /actuator/prometheus 13 | scheme: http 14 | - name: "petclinic-customers" 15 | selector: 16 | matchLabels: 17 | svc: customers 18 | namespaceSelector: 19 | matchNames: 20 | - default 21 | endpoints: 22 | - port: http 23 | path: /actuator/prometheus 24 | scheme: http 25 | - name: "petclinic-vets" 26 | selector: 27 | matchLabels: 28 | svc: vets 29 | namespaceSelector: 30 | matchNames: 31 | - default 32 | endpoints: 33 | - port: http 34 | path: /actuator/prometheus 35 | scheme: http 36 | - name: "petclinic-visits" 37 | selector: 38 | matchLabels: 39 | svc: visits 40 | namespaceSelector: 41 | matchNames: 42 | - default 43 | endpoints: 44 | - port: http 45 | path: /actuator/prometheus 46 | scheme: http 47 | -------------------------------------------------------------------------------- /ch08/08/jmeter/petclinic_test_plan.jmx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | false 7 | true 8 | false 9 | 10 | 11 | 12 | PETCLINC_HOST 13 | 192.168.64.10 14 | = 15 | 16 | 17 | PETCLINIC_PORT 18 | 31080 19 | = 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ${PETCLINC_HOST} 31 | ${PETCLINIC_PORT} 32 | 33 | 34 | 35 | 6 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Accept 44 | application/json, text/plain, */* 45 | 46 | 47 | Content-Type 48 | application/json;charset=UTF-8 49 | 50 | 51 | Accept-Encoding 52 | gzip, deflate, br 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 2 61 | 0 62 | 0 63 | 300 64 | 30 65 | 66 | 67 | 68 | false 69 | -1 70 | 71 | continue 72 | 73 | 74 | 75 | PET_TYPE 76 | 77 | 1 78 | 6 79 | 80 | false 81 | 82 | 83 | 84 | 300 85 | 100.0 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | /api/customer/owners 97 | GET 98 | true 99 | false 100 | true 101 | false 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 200 110 | 111 | 112 | Assertion.response_code 113 | false 114 | 8 115 | 116 | 117 | 118 | 119 | true 120 | 121 | 122 | 123 | false 124 | { 125 | "firstName":"Firstname", 126 | "lastName":"Lastname", 127 | "address":"Adress", 128 | "city":"City", 129 | "telephone":"0000000000" 130 | } 131 | = 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | /api/customer/owners 140 | POST 141 | true 142 | false 143 | true 144 | false 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 201 153 | 154 | 155 | Assertion.response_code 156 | false 157 | 8 158 | 159 | 160 | 161 | OWNER_ID 162 | $.id 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | /api/bff/owners/${OWNER_ID} 176 | GET 177 | true 178 | false 179 | true 180 | false 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 200 189 | 190 | 191 | Assertion.response_code 192 | false 193 | 8 194 | 195 | 196 | 197 | 198 | true 199 | 200 | 201 | 202 | false 203 | { 204 | "id":"${OWNER_ID}", 205 | "firstName":"Firstname", 206 | "lastName":"Lastname${OWNER_ID}", 207 | "address":"Adress${OWNER_ID}", 208 | "city":"City${OWNER_ID}", 209 | "telephone":"1111111111" 210 | } 211 | = 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | /api/customer/owners/${OWNER_ID} 220 | PUT 221 | true 222 | false 223 | true 224 | false 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 204 233 | 234 | 235 | Assertion.response_code 236 | false 237 | 8 238 | 239 | 240 | 241 | 242 | true 243 | 244 | 245 | 246 | false 247 | { 248 | "name":"Pet", 249 | "birthDate":"2018-12-31T23:00:00.000Z", 250 | "typeId":"${PET_TYPE}" 251 | } 252 | = 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | /api/customer/owners/${OWNER_ID}/pets 261 | POST 262 | true 263 | false 264 | true 265 | false 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 201 274 | 275 | 276 | Assertion.response_code 277 | false 278 | 8 279 | 280 | 281 | 282 | PET_ID 283 | $.id 284 | 285 | 286 | 287 | 288 | 289 | 1 290 | 291 | 292 | 293 | true 294 | 295 | 296 | 297 | false 298 | { 299 | "name":"Pet", 300 | "birthDate":"2018-12-31T23:00:00.000Z", 301 | "typeId":"${PET_TYPE}" 302 | } 303 | = 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | /api/customer/owners/${OWNER_ID}/pets 312 | POST 313 | true 314 | false 315 | true 316 | false 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 201 325 | 326 | 327 | Assertion.response_code 328 | false 329 | 8 330 | 331 | 332 | 333 | 334 | 335 | true 336 | 337 | 338 | 339 | false 340 | { 341 | "id": ${PET_ID}, 342 | "name":"Pet${OWNER_ID}", 343 | "birthDate":"2018-12-31T23:00:00.000Z", 344 | "typeId":"${PET_TYPE}" 345 | } 346 | = 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | /api/customer/owners/${OWNER_ID}/pets/${PET_ID} 355 | PUT 356 | true 357 | false 358 | true 359 | false 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 204 368 | 369 | 370 | Assertion.response_code 371 | false 372 | 8 373 | 374 | 375 | 376 | 377 | true 378 | 379 | 380 | 381 | false 382 | { 383 | "date":"2019-03-15", 384 | "description":"Visit" 385 | } 386 | = 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | /api/visit/owners/${OWNER_ID}/pets/${PET_ID}/visits 395 | POST 396 | true 397 | false 398 | true 399 | false 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 201 408 | 409 | 410 | Assertion.response_code 411 | false 412 | 8 413 | 414 | 415 | 416 | 417 | 1 418 | 419 | 420 | 421 | true 422 | 423 | 424 | 425 | false 426 | { 427 | "date":"2019-03-15", 428 | "description":"Visit" 429 | } 430 | = 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | /api/visit/owners/${OWNER_ID}/pets/${PET_ID}/visits 439 | POST 440 | true 441 | false 442 | true 443 | false 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 201 452 | 453 | 454 | Assertion.response_code 455 | false 456 | 8 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | /api/vet/vets 470 | GET 471 | true 472 | false 473 | true 474 | false 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 200 483 | 484 | 485 | Assertion.response_code 486 | false 487 | 8 488 | 489 | 490 | 491 | 492 | false 493 | 494 | saveConfig 495 | 496 | 497 | true 498 | true 499 | true 500 | 501 | true 502 | true 503 | true 504 | true 505 | false 506 | true 507 | true 508 | false 509 | false 510 | false 511 | true 512 | false 513 | false 514 | false 515 | true 516 | 0 517 | true 518 | true 519 | true 520 | true 521 | true 522 | true 523 | 524 | 525 | 526 | 527 | 528 | 529 | false 530 | 531 | saveConfig 532 | 533 | 534 | true 535 | true 536 | true 537 | 538 | true 539 | true 540 | true 541 | true 542 | false 543 | true 544 | true 545 | false 546 | false 547 | false 548 | true 549 | false 550 | false 551 | false 552 | true 553 | 0 554 | true 555 | true 556 | true 557 | true 558 | true 559 | true 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | -------------------------------------------------------------------------------- /ch08/08/petclinic_msa_dashboard_config.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: petclinic-msa-dashboard 5 | namespace: monitoring 6 | labels: 7 | grafana_dashboard: "1" 8 | data: 9 | petclinic-msa-dashboard.json: | 10 | { 11 | "__requires": [], 12 | "annotations": { 13 | "list": [ 14 | { 15 | "builtIn": 1, 16 | "datasource": "-- Grafana --", 17 | "enable": true, 18 | "hide": true, 19 | "iconColor": "rgba(0, 211, 255, 1)", 20 | "name": "Annotations & Alerts", 21 | "type": "dashboard" 22 | } 23 | ] 24 | }, 25 | "editable": true, 26 | "gnetId": null, 27 | "graphTooltip": 0, 28 | "id": null, 29 | "iteration": 1539967676482, 30 | "links": [], 31 | "panels": [ 32 | { 33 | "aliasColors": {}, 34 | "bars": false, 35 | "dashLength": 10, 36 | "dashes": false, 37 | "datasource": "Prometheus", 38 | "fill": 1, 39 | "gridPos": { 40 | "h": 9, 41 | "w": 12, 42 | "x": 0, 43 | "y": 0 44 | }, 45 | "id": 11, 46 | "legend": { 47 | "avg": false, 48 | "current": true, 49 | "max": false, 50 | "min": false, 51 | "show": true, 52 | "total": false, 53 | "values": true 54 | }, 55 | "lines": true, 56 | "linewidth": 1, 57 | "links": [], 58 | "nullPointMode": "null", 59 | "percentage": false, 60 | "pointradius": 5, 61 | "points": false, 62 | "renderer": "flot", 63 | "seriesOverrides": [], 64 | "spaceLength": 10, 65 | "stack": false, 66 | "steppedLine": false, 67 | "targets": [ 68 | { 69 | "expr": "sum(rate(http_server_requests_seconds_sum{status!~\"5..\"}[1m]))/sum(rate(http_server_requests_seconds_count{ status!~\"5..\"}[1m]))", 70 | "format": "time_series", 71 | "intervalFactor": 1, 72 | "legendFormat": "HTTP - AVG", 73 | "refId": "A" 74 | }, 75 | { 76 | "expr": "max(http_server_requests_seconds_max{status!~\"5..\"})", 77 | "format": "time_series", 78 | "intervalFactor": 1, 79 | "legendFormat": "HTTP - MAX", 80 | "refId": "B" 81 | } 82 | ], 83 | "thresholds": [], 84 | "timeFrom": null, 85 | "timeShift": null, 86 | "title": "HTTP Request Latency", 87 | "tooltip": { 88 | "shared": true, 89 | "sort": 0, 90 | "value_type": "individual" 91 | }, 92 | "type": "graph", 93 | "xaxis": { 94 | "buckets": null, 95 | "mode": "time", 96 | "name": null, 97 | "show": true, 98 | "values": [] 99 | }, 100 | "yaxes": [ 101 | { 102 | "decimals": null, 103 | "format": "s", 104 | "label": null, 105 | "logBase": 1, 106 | "max": null, 107 | "min": "0", 108 | "show": true 109 | }, 110 | { 111 | "format": "short", 112 | "label": null, 113 | "logBase": 1, 114 | "max": null, 115 | "min": null, 116 | "show": true 117 | } 118 | ] 119 | }, 120 | { 121 | "aliasColors": {}, 122 | "bars": false, 123 | "dashLength": 10, 124 | "dashes": false, 125 | "datasource": "Prometheus", 126 | "fill": 1, 127 | "gridPos": { 128 | "h": 9, 129 | "w": 12, 130 | "x": 12, 131 | "y": 0 132 | }, 133 | "id": 9, 134 | "legend": { 135 | "avg": false, 136 | "current": true, 137 | "max": true, 138 | "min": false, 139 | "show": true, 140 | "total": false, 141 | "values": true 142 | }, 143 | "lines": true, 144 | "linewidth": 1, 145 | "links": [], 146 | "nullPointMode": "null", 147 | "percentage": false, 148 | "pointradius": 0.5, 149 | "points": true, 150 | "renderer": "flot", 151 | "seriesOverrides": [], 152 | "spaceLength": 10, 153 | "stack": false, 154 | "steppedLine": false, 155 | "targets": [ 156 | { 157 | "expr": "sum(rate(http_server_requests_seconds_count[1m]))", 158 | "format": "time_series", 159 | "interval": "", 160 | "intervalFactor": 1, 161 | "legendFormat": "request - ok", 162 | "refId": "A" 163 | }, 164 | { 165 | "expr": "sum(rate(http_server_requests_seconds_count{status=~\"5..\"}[1m]))", 166 | "format": "time_series", 167 | "interval": "", 168 | "intervalFactor": 1, 169 | "legendFormat": "request - err", 170 | "refId": "B" 171 | } 172 | ], 173 | "thresholds": [], 174 | "timeFrom": null, 175 | "timeShift": null, 176 | "title": "HTTP Request Activity", 177 | "tooltip": { 178 | "shared": true, 179 | "sort": 0, 180 | "value_type": "individual" 181 | }, 182 | "type": "graph", 183 | "xaxis": { 184 | "buckets": null, 185 | "mode": "time", 186 | "name": null, 187 | "show": true, 188 | "values": [] 189 | }, 190 | "yaxes": [ 191 | { 192 | "format": "ops", 193 | "label": null, 194 | "logBase": 1, 195 | "max": null, 196 | "min": "0", 197 | "show": true 198 | }, 199 | { 200 | "format": "short", 201 | "label": null, 202 | "logBase": 1, 203 | "max": null, 204 | "min": null, 205 | "show": true 206 | } 207 | ] 208 | }, 209 | { 210 | "cacheTimeout": null, 211 | "colorBackground": false, 212 | "colorValue": false, 213 | "colors": [ 214 | "#299c46", 215 | "rgba(237, 129, 40, 0.89)", 216 | "#d44a3a" 217 | ], 218 | "datasource": "Prometheus", 219 | "format": "none", 220 | "gauge": { 221 | "maxValue": 100, 222 | "minValue": 0, 223 | "show": false, 224 | "thresholdLabels": false, 225 | "thresholdMarkers": true 226 | }, 227 | "gridPos": { 228 | "h": 5, 229 | "w": 6, 230 | "x": 0, 231 | "y": 9 232 | }, 233 | "id": 2, 234 | "interval": null, 235 | "links": [], 236 | "mappingType": 1, 237 | "mappingTypes": [ 238 | { 239 | "name": "value to text", 240 | "value": 1 241 | }, 242 | { 243 | "name": "range to text", 244 | "value": 2 245 | } 246 | ], 247 | "maxDataPoints": 100, 248 | "nullPointMode": "connected", 249 | "nullText": null, 250 | "postfix": "", 251 | "postfixFontSize": "50%", 252 | "prefix": "", 253 | "prefixFontSize": "50%", 254 | "rangeMaps": [ 255 | { 256 | "from": "null", 257 | "text": "N/A", 258 | "to": "null" 259 | } 260 | ], 261 | "sparkline": { 262 | "fillColor": "rgba(31, 118, 189, 0.18)", 263 | "full": false, 264 | "lineColor": "rgb(31, 120, 193)", 265 | "show": false 266 | }, 267 | "tableColumn": "", 268 | "targets": [ 269 | { 270 | "expr": "sum(petclinic_owner_seconds_count{method=\"PUT\", status=\"204\"})", 271 | "format": "time_series", 272 | "instant": true, 273 | "intervalFactor": 1, 274 | "refId": "A" 275 | } 276 | ], 277 | "thresholds": "", 278 | "title": "Owners Updated", 279 | "type": "singlestat", 280 | "valueFontSize": "80%", 281 | "valueMaps": [ 282 | { 283 | "op": "=", 284 | "text": "N/A", 285 | "value": "null" 286 | } 287 | ], 288 | "valueName": "avg" 289 | }, 290 | { 291 | "cacheTimeout": null, 292 | "colorBackground": false, 293 | "colorValue": false, 294 | "colors": [ 295 | "#299c46", 296 | "rgba(237, 129, 40, 0.89)", 297 | "#d44a3a" 298 | ], 299 | "datasource": "Prometheus", 300 | "format": "none", 301 | "gauge": { 302 | "maxValue": 100, 303 | "minValue": 0, 304 | "show": false, 305 | "thresholdLabels": false, 306 | "thresholdMarkers": true 307 | }, 308 | "gridPos": { 309 | "h": 5, 310 | "w": 6, 311 | "x": 6, 312 | "y": 9 313 | }, 314 | "id": 3, 315 | "interval": null, 316 | "links": [], 317 | "mappingType": 1, 318 | "mappingTypes": [ 319 | { 320 | "name": "value to text", 321 | "value": 1 322 | }, 323 | { 324 | "name": "range to text", 325 | "value": 2 326 | } 327 | ], 328 | "maxDataPoints": 100, 329 | "nullPointMode": "connected", 330 | "nullText": null, 331 | "postfix": "", 332 | "postfixFontSize": "50%", 333 | "prefix": "", 334 | "prefixFontSize": "50%", 335 | "rangeMaps": [ 336 | { 337 | "from": "null", 338 | "text": "N/A", 339 | "to": "null" 340 | } 341 | ], 342 | "sparkline": { 343 | "fillColor": "rgba(31, 118, 189, 0.18)", 344 | "full": false, 345 | "lineColor": "rgb(31, 120, 193)", 346 | "show": false 347 | }, 348 | "tableColumn": "", 349 | "targets": [ 350 | { 351 | "expr": "sum(petclinic_owner_seconds_count{method=\"POST\", status=\"201\"})", 352 | "format": "time_series", 353 | "instant": true, 354 | "intervalFactor": 1, 355 | "legendFormat": "", 356 | "refId": "A" 357 | } 358 | ], 359 | "thresholds": "", 360 | "title": "Owners Created", 361 | "type": "singlestat", 362 | "valueFontSize": "80%", 363 | "valueMaps": [ 364 | { 365 | "op": "=", 366 | "text": "N/A", 367 | "value": "null" 368 | } 369 | ], 370 | "valueName": "avg" 371 | }, 372 | { 373 | "cacheTimeout": null, 374 | "colorBackground": false, 375 | "colorValue": false, 376 | "colors": [ 377 | "#299c46", 378 | "rgba(237, 129, 40, 0.89)", 379 | "#d44a3a" 380 | ], 381 | "datasource": "Prometheus", 382 | "format": "none", 383 | "gauge": { 384 | "maxValue": 100, 385 | "minValue": 0, 386 | "show": false, 387 | "thresholdLabels": false, 388 | "thresholdMarkers": true 389 | }, 390 | "gridPos": { 391 | "h": 5, 392 | "w": 6, 393 | "x": 12, 394 | "y": 9 395 | }, 396 | "id": 4, 397 | "interval": null, 398 | "links": [], 399 | "mappingType": 1, 400 | "mappingTypes": [ 401 | { 402 | "name": "value to text", 403 | "value": 1 404 | }, 405 | { 406 | "name": "range to text", 407 | "value": 2 408 | } 409 | ], 410 | "maxDataPoints": 100, 411 | "nullPointMode": "connected", 412 | "nullText": null, 413 | "postfix": "", 414 | "postfixFontSize": "50%", 415 | "prefix": "", 416 | "prefixFontSize": "50%", 417 | "rangeMaps": [ 418 | { 419 | "from": "null", 420 | "text": "N/A", 421 | "to": "null" 422 | } 423 | ], 424 | "sparkline": { 425 | "fillColor": "rgba(31, 118, 189, 0.18)", 426 | "full": false, 427 | "lineColor": "rgb(31, 120, 193)", 428 | "show": false 429 | }, 430 | "tableColumn": "", 431 | "targets": [ 432 | { 433 | "expr": "sum(petclinic_pet_seconds_count{method=\"POST\", status=\"201\"})", 434 | "format": "time_series", 435 | "instant": true, 436 | "intervalFactor": 1, 437 | "legendFormat": "", 438 | "refId": "A" 439 | } 440 | ], 441 | "thresholds": "", 442 | "title": "Pets Created", 443 | "type": "singlestat", 444 | "valueFontSize": "80%", 445 | "valueMaps": [ 446 | { 447 | "op": "=", 448 | "text": "N/A", 449 | "value": "null" 450 | } 451 | ], 452 | "valueName": "avg" 453 | }, 454 | { 455 | "cacheTimeout": null, 456 | "colorBackground": false, 457 | "colorValue": false, 458 | "colors": [ 459 | "#299c46", 460 | "rgba(237, 129, 40, 0.89)", 461 | "#d44a3a" 462 | ], 463 | "datasource": "Prometheus", 464 | "format": "none", 465 | "gauge": { 466 | "maxValue": 100, 467 | "minValue": 0, 468 | "show": false, 469 | "thresholdLabels": false, 470 | "thresholdMarkers": true 471 | }, 472 | "gridPos": { 473 | "h": 5, 474 | "w": 6, 475 | "x": 18, 476 | "y": 9 477 | }, 478 | "id": 5, 479 | "interval": null, 480 | "links": [], 481 | "mappingType": 1, 482 | "mappingTypes": [ 483 | { 484 | "name": "value to text", 485 | "value": 1 486 | }, 487 | { 488 | "name": "range to text", 489 | "value": 2 490 | } 491 | ], 492 | "maxDataPoints": 100, 493 | "nullPointMode": "connected", 494 | "nullText": null, 495 | "postfix": "", 496 | "postfixFontSize": "50%", 497 | "prefix": "", 498 | "prefixFontSize": "50%", 499 | "rangeMaps": [ 500 | { 501 | "from": "null", 502 | "text": "N/A", 503 | "to": "null" 504 | } 505 | ], 506 | "sparkline": { 507 | "fillColor": "rgba(31, 118, 189, 0.18)", 508 | "full": false, 509 | "lineColor": "rgb(31, 120, 193)", 510 | "show": false 511 | }, 512 | "tableColumn": "Value", 513 | "targets": [ 514 | { 515 | "expr": "sum(petclinic_visit_seconds_count{method=\"POST\", status=\"201\"})", 516 | "format": "time_series", 517 | "instant": true, 518 | "intervalFactor": 1, 519 | "legendFormat": "", 520 | "refId": "A" 521 | } 522 | ], 523 | "thresholds": "", 524 | "title": "Visit Created", 525 | "type": "singlestat", 526 | "valueFontSize": "80%", 527 | "valueMaps": [ 528 | { 529 | "op": "=", 530 | "text": "N/A", 531 | "value": "null" 532 | } 533 | ], 534 | "valueName": "avg" 535 | }, 536 | { 537 | "aliasColors": {}, 538 | "bars": true, 539 | "dashLength": 10, 540 | "dashes": false, 541 | "datasource": "Prometheus", 542 | "fill": 1, 543 | "gridPos": { 544 | "h": 8, 545 | "w": 24, 546 | "x": 0, 547 | "y": 14 548 | }, 549 | "id": 7, 550 | "legend": { 551 | "alignAsTable": false, 552 | "avg": false, 553 | "current": false, 554 | "hideEmpty": false, 555 | "hideZero": true, 556 | "max": true, 557 | "min": false, 558 | "rightSide": false, 559 | "show": true, 560 | "total": false, 561 | "values": true 562 | }, 563 | "lines": false, 564 | "linewidth": 1, 565 | "links": [], 566 | "nullPointMode": "null", 567 | "percentage": false, 568 | "pointradius": 5, 569 | "points": false, 570 | "renderer": "flot", 571 | "seriesOverrides": [], 572 | "spaceLength": 10, 573 | "stack": true, 574 | "steppedLine": false, 575 | "targets": [ 576 | { 577 | "expr": "sum(petclinic_owner_seconds_count{method=\"POST\", status=\"201\"})", 578 | "format": "time_series", 579 | "instant": false, 580 | "intervalFactor": 1, 581 | "legendFormat": "owner create", 582 | "refId": "A" 583 | }, 584 | { 585 | "expr": "sum(petclinic_pet_seconds_count{method=\"POST\", status=\"201\"})", 586 | "format": "time_series", 587 | "intervalFactor": 1, 588 | "legendFormat": "pet create", 589 | "refId": "B" 590 | }, 591 | { 592 | "expr": "sum(petclinic_visit_seconds_count{method=\"POST\", status=\"201\"})", 593 | "format": "time_series", 594 | "intervalFactor": 1, 595 | "legendFormat": "visit create", 596 | "refId": "C" 597 | }, 598 | { 599 | "expr": "sum(petclinic_owner_seconds_count{method=\"PUT\", status=\"204\"})", 600 | "format": "time_series", 601 | "intervalFactor": 1, 602 | "legendFormat": "owner update", 603 | "refId": "D" 604 | } 605 | ], 606 | "thresholds": [], 607 | "timeFrom": null, 608 | "timeShift": null, 609 | "title": "SPC Business Histogram", 610 | "tooltip": { 611 | "shared": true, 612 | "sort": 0, 613 | "value_type": "individual" 614 | }, 615 | "type": "graph", 616 | "xaxis": { 617 | "buckets": null, 618 | "mode": "time", 619 | "name": null, 620 | "show": true, 621 | "values": [] 622 | }, 623 | "yaxes": [ 624 | { 625 | "format": "short", 626 | "label": null, 627 | "logBase": 1, 628 | "max": null, 629 | "min": null, 630 | "show": true 631 | }, 632 | { 633 | "format": "short", 634 | "label": null, 635 | "logBase": 1, 636 | "max": null, 637 | "min": null, 638 | "show": true 639 | } 640 | ] 641 | } 642 | ], 643 | "refresh": "30s", 644 | "schemaVersion": 16, 645 | "style": "dark", 646 | "tags": [], 647 | "templating": { 648 | "list": [ 649 | { 650 | "auto": true, 651 | "auto_count": 1, 652 | "auto_min": "10s", 653 | "current": { 654 | "text": "auto", 655 | "value": "$__auto_interval_timeRange" 656 | }, 657 | "hide": 0, 658 | "label": null, 659 | "name": "timeRange", 660 | "options": [ 661 | { 662 | "selected": true, 663 | "text": "auto", 664 | "value": "$__auto_interval_timeRange" 665 | }, 666 | { 667 | "selected": false, 668 | "text": "1m", 669 | "value": "1m" 670 | }, 671 | { 672 | "selected": false, 673 | "text": "10m", 674 | "value": "10m" 675 | }, 676 | { 677 | "selected": false, 678 | "text": "30m", 679 | "value": "30m" 680 | }, 681 | { 682 | "selected": false, 683 | "text": "1h", 684 | "value": "1h" 685 | }, 686 | { 687 | "selected": false, 688 | "text": "6h", 689 | "value": "6h" 690 | }, 691 | { 692 | "selected": false, 693 | "text": "12h", 694 | "value": "12h" 695 | }, 696 | { 697 | "selected": false, 698 | "text": "1d", 699 | "value": "1d" 700 | }, 701 | { 702 | "selected": false, 703 | "text": "7d", 704 | "value": "7d" 705 | }, 706 | { 707 | "selected": false, 708 | "text": "14d", 709 | "value": "14d" 710 | }, 711 | { 712 | "selected": false, 713 | "text": "30d", 714 | "value": "30d" 715 | } 716 | ], 717 | "query": "1m,10m,30m,1h,6h,12h,1d,7d,14d,30d", 718 | "refresh": 2, 719 | "type": "interval" 720 | } 721 | ] 722 | }, 723 | "time": { 724 | "from": "now-1h", 725 | "to": "now" 726 | }, 727 | "timepicker": { 728 | "refresh_intervals": [ 729 | "5s", 730 | "10s", 731 | "30s", 732 | "1m", 733 | "5m", 734 | "15m", 735 | "30m", 736 | "1h", 737 | "2h", 738 | "1d" 739 | ], 740 | "time_options": [ 741 | "5m", 742 | "15m", 743 | "1h", 744 | "6h", 745 | "12h", 746 | "24h", 747 | "2d", 748 | "7d", 749 | "30d" 750 | ] 751 | }, 752 | "timezone": "", 753 | "title": "Spring Petclinic Metrics", 754 | "uid": "69JXeR0iw", 755 | "version": 1 756 | } 757 | -------------------------------------------------------------------------------- /ch08/08/values_servicemonitor.yml: -------------------------------------------------------------------------------- 1 | prometheus: 2 | additionalServiceMonitors: 3 | - name: "petclinic-gateway" 4 | selector: 5 | matchLabels: 6 | svc: gateway 7 | namespaceSelector: 8 | matchNames: 9 | - default 10 | endpoints: 11 | - port: http 12 | path: /actuator/prometheus 13 | scheme: http 14 | - name: "petclinic-web" 15 | selector: 16 | matchLabels: 17 | svc: web 18 | namespaceSelector: 19 | matchNames: 20 | - default 21 | endpoints: 22 | - port: http 23 | path: /actuator/prometheus 24 | scheme: http 25 | - name: "petclinic-customers" 26 | selector: 27 | matchLabels: 28 | svc: customers 29 | namespaceSelector: 30 | matchNames: 31 | - default 32 | endpoints: 33 | - port: http 34 | path: /actuator/prometheus 35 | scheme: http 36 | - name: "petclinic-vets" 37 | selector: 38 | matchLabels: 39 | svc: vets 40 | namespaceSelector: 41 | matchNames: 42 | - default 43 | endpoints: 44 | - port: http 45 | path: /actuator/prometheus 46 | scheme: http 47 | - name: "petclinic-visits" 48 | selector: 49 | matchLabels: 50 | svc: visits 51 | namespaceSelector: 52 | matchNames: 53 | - default 54 | endpoints: 55 | - port: http 56 | path: /actuator/prometheus 57 | scheme: http 58 | -------------------------------------------------------------------------------- /ch08/10/skywalking-oap.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: oap 5 | namespace: skywalking 6 | spec: 7 | replicas: 1 8 | selector: 9 | matchLabels: 10 | app: oap 11 | release: skywalking 12 | template: 13 | metadata: 14 | labels: 15 | app: oap 16 | release: skywalking 17 | spec: 18 | containers: 19 | - name: oap 20 | image: apache/skywalking-oap-server:6.6.0-es6 21 | imagePullPolicy: IfNotPresent 22 | ports: 23 | - containerPort: 11800 24 | name: grpc 25 | - containerPort: 12800 26 | name: rest 27 | --- 28 | apiVersion: v1 29 | kind: Service 30 | metadata: 31 | name: oap 32 | namespace: skywalking 33 | labels: 34 | service: oap 35 | spec: 36 | ports: 37 | - port: 12800 38 | name: rest 39 | - port: 11800 40 | name: grpc 41 | - port: 1234 42 | name: page 43 | selector: 44 | app: oap 45 | -------------------------------------------------------------------------------- /ch08/10/skywalking-ui.yml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: ui-deployment 5 | namespace: skywalking 6 | labels: 7 | app: ui 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | app: ui 13 | template: 14 | metadata: 15 | labels: 16 | app: ui 17 | spec: 18 | containers: 19 | - name: ui 20 | image: apache/skywalking-ui:6.6.0 21 | ports: 22 | - containerPort: 8080 23 | name: page 24 | env: 25 | - name: SW_OAP_ADDRESS 26 | value: oap:12800 27 | --- 28 | apiVersion: v1 29 | kind: Service 30 | metadata: 31 | name: ui 32 | namespace: skywalking 33 | labels: 34 | service: ui 35 | spec: 36 | ports: 37 | - port: 8080 38 | name: page 39 | nodePort: 31234 40 | type: NodePort 41 | selector: 42 | app: ui 43 | -------------------------------------------------------------------------------- /ch08/11/.gitignore: -------------------------------------------------------------------------------- 1 | apache-skywalking-apm-bin/ 2 | apache-skywalking-apm-6.6.0.tar.gz -------------------------------------------------------------------------------- /ch08/11/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://skywalking.apache.org/zh/blog/2019-08-30-how-to-use-Skywalking-Agent.html 2 | # 执行镜像构建前先下载skywalking包到当前目录 3 | # wget http://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/6.6.0/apache-skywalking-apm-6.6.0.tar.gz && tar -zxvf apache-skywalking-apm-6.6.0.tar.gz 4 | FROM busybox:latest 5 | 6 | ENV LANG=C.UTF-8 7 | 8 | RUN set -eux && mkdir -p /usr/skywalking/agent/ 9 | 10 | ADD apache-skywalking-apm-bin/agent/ /usr/skywalking/agent/ 11 | 12 | WORKDIR / 13 | 14 | 15 | 16 | --------------------------------------------------------------------------------