Skip to content

Commit

Permalink
update es
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhibin.lzb authored and linuzb committed Oct 26, 2023
1 parent 9b29eb2 commit 1eb8fb4
Show file tree
Hide file tree
Showing 3,145 changed files with 844 additions and 1,025,698 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
# Generate multi-platform images, see https://github.com/docker-library/bashbrew/blob/v0.1.1/architecture/oci-platform.go
platforms: |
linux/amd64
linux/arm64
# docker build arg
build-args: |
GOARCH=$(go env GOARCH)
# Generate two Docker tags: ${APP_VERSION} 和 latest
tags: |
${{ env.LUNETTES_DOCKERHUB_REPO }}:latest
Expand All @@ -58,6 +62,7 @@ jobs:
# Generate multi-platform images, see https://github.com/docker-library/bashbrew/blob/v0.1.1/architecture/oci-platform.go
platforms: |
linux/amd64
linux/arm64
# docker build arg
build-args: |
PLUGINS=${{ env.GRAFANA_PLUGINS }}
Expand Down
25 changes: 11 additions & 14 deletions build/docker/Dockerfile.lunettes
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# Build the aggregator binary
ARG GOARCH=amd64
FROM golang:1.20.3 as builder

# Copy in the go src
WORKDIR /go/src/github.com/alipay/container-observability-service
COPY cmd/ cmd/
COPY internal internal
COPY vendor/ vendor/
COPY pkg/ pkg/
COPY statics/ statics/
WORKDIR /src
COPY . .

RUN ls
# Build
RUN GO111MODULE=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -o aggregator github.com/alipay/container-observability-service/cmd/aggregator
RUN GO111MODULE=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -o auditinstaller github.com/alipay/container-observability-service/cmd/audit_init
RUN GO111MODULE=off CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -o grafanadi github.com/alipay/container-observability-service/cmd/grafanadi
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -v -a -o aggregator ./cmd/aggregator
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -v -a -o auditinstaller ./cmd/audit_init
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} go build -v -a -o grafanadi ./cmd/grafanadi

# Copy the aggregator binary into a thin image
FROM ubuntu:devel
WORKDIR /
COPY --from=builder /go/src/github.com/alipay/container-observability-service/aggregator .
COPY --from=builder /go/src/github.com/alipay/container-observability-service/statics ./statics
COPY --from=builder /go/src/github.com/alipay/container-observability-service/auditinstaller .
COPY --from=builder /go/src/github.com/alipay/container-observability-service/grafanadi .
COPY --from=builder /src/aggregator .
COPY --from=builder /src/statics ./statics
COPY --from=builder /src/auditinstaller .
COPY --from=builder /src/grafanadi .
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ metadata:
namespace: {{ .Values.namespace }}
data:
elasticsearch.yml: |
cluster.name: my-es
# node.name: dev-es-kibana
cluster.name: lunettes-es
discovery.type: single-node
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*,spans*
path.data: /data
search.max_open_scroll_context: 10000
search.max_open_scroll_context: 10000
xpack.security.enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
env:
- name: ES_JAVA_OPTS
value: "{{ .Values.esJavaOptions }}"
- name: ATTEMPT_SECURITY_AUTO_CONFIG
value: "false"
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- containerPort: 9200
Expand Down
12 changes: 6 additions & 6 deletions deploy/helm/lunettes/templates/grafana/grafana-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=Cluster.keyword&timeattr=Created&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=Cluster.keyword&timeattr=Created&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down Expand Up @@ -2570,7 +2570,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=SLOViolationReason.keyword&timeattr=Created&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=SLOViolationReason.keyword&timeattr=Created&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down Expand Up @@ -2645,7 +2645,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason:success&percentiles=DeliveryDuration&timeattr=Created&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason:success&percentiles=DeliveryDuration&timeattr=Created&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down Expand Up @@ -2746,7 +2746,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=Cluster.keyword&overtime=$timestep&timeattr=Created&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=Cluster.keyword&overtime=$timestep&timeattr=Created&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down Expand Up @@ -2846,7 +2846,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=SLOViolationReason.keyword&timeattr=Created&overtime=$timestep&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason.keyword:$deliveryresult&terms=SLOViolationReason.keyword&timeattr=Created&overtime=$timestep&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down Expand Up @@ -2947,7 +2947,7 @@ data:
"root_selector": "",
"source": "url",
"type": "json",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=data&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason:success&percentiles=DeliveryDuration&timeattr=Created&overtime=$timestep&gte=$__from&lte=$__to",
"url": "http://grafanadi.lunettes.svc.cluster.local:8080/elasticaggregations?index=slo_data&doctype=_doc&filters=Namespace.keyword:$namespace*Cluster.keyword:$cluster*SLOViolationReason:success&percentiles=DeliveryDuration&timeattr=Created&overtime=$timestep&gte=$__from&lte=$__to",
"url_options": {
"data": "",
"method": "GET"
Expand Down
1 change: 0 additions & 1 deletion deploy/helm/lunettes/templates/kibana/kibana-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ data:
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: "http://es-cluster-svc.{{ .Values.namespace }}:9200"
kibana.index: ".kibana"
kind: ConfigMap
metadata:
name: kibana-config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ spec:
- --v=6
- --apiserver-enabled={{ .Values.apiserverEnabled }}
- --log_dir=/logs
- --logtostderr=true
- --es-buffer-duration=10s
- --es-fetch-interval=1s
- --es-endpoint=http://es-cluster-svc.{{ .Values.namespace }}:9200
Expand Down
6 changes: 3 additions & 3 deletions deploy/helm/lunettes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ grafanaResources:
memory: 500Mi

# kibana
kibanaImage: docker.elastic.co/kibana/kibana:6.6.0
kibanaImage: kibana:7.17.13
kibanaNodePort: 30610
kibanaResources:
limits:
Expand All @@ -73,7 +73,7 @@ kibanaResources:
memory: 500Mi

# filebeat
filebeatImage: elastic/filebeat:6.6.2
filebeatImage: elastic/filebeat:7.17.14
filebeatResources:
limits:
cpu: 100m
Expand All @@ -83,7 +83,7 @@ filebeatResources:
memory: 200Mi

# elasticsearch
elasticImage: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
elasticImage: elasticsearch:7.17.13
elasticInitImage: busybox:stable
elastic1NodePort: 30920
elastic2NodePort: 30930
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/iancoleman/orderedmap v0.1.0
github.com/json-iterator/go v1.1.12
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
github.com/olivere/elastic v6.2.35+incompatible
github.com/olivere/elastic/v7 v7.0.32
github.com/pkg/errors v0.9.1
github.com/prashantv/gostub v1.1.0
github.com/prometheus/client_golang v1.10.0
Expand Down Expand Up @@ -46,7 +46,6 @@ require (
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
Expand All @@ -61,7 +60,8 @@ require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLi
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down Expand Up @@ -190,8 +189,8 @@ github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0L
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
Expand Down Expand Up @@ -310,6 +309,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -342,8 +343,9 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
Expand Down Expand Up @@ -383,8 +385,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 h1:Yl0tPBa8QPjGmesFh1D0rDy+q1Twx6FyU7VWHi8wZbI=
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852/go.mod h1:eqOVx5Vwu4gd2mmMZvVZsgIqNSaW3xxRThUJ0k/TPk4=
github.com/olivere/elastic v6.2.35+incompatible h1:MMklYDy2ySi01s123CB2WLBuDMzFX4qhFcA5tKWJPgM=
github.com/olivere/elastic v6.2.35+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/olivere/elastic/v7 v7.0.32 h1:R7CXvbu8Eq+WlsLgxmKVKPox0oOwAE/2T9Si5BnvK6E=
github.com/olivere/elastic/v7 v7.0.32/go.mod h1:c7PVmLe3Fxq77PIfY/bZmxY/TAamBhCzZ8xDOE09a9k=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
18 changes: 18 additions & 0 deletions internal/grafanadi/handler/containerevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"errors"
"fmt"
"net/http"
"time"

"github.com/alipay/container-observability-service/internal/grafanadi/service"
interutils "github.com/alipay/container-observability-service/internal/grafanadi/utils"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/data_access"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/model"
"github.com/alipay/container-observability-service/pkg/metrics"
"github.com/alipay/container-observability-service/pkg/utils"
)

Expand All @@ -19,7 +22,22 @@ type ContainerEventsHandler struct {
}

func (handler *ContainerEventsHandler) GetContainerEventsData(key, value string) (int, interface{}, error) {
podYamls := make([]*model.PodYaml, 0)
podLifephases := make([]*model.LifePhase, 0)
if value == "" {
return http.StatusOK, nil, nil
}

begin := time.Now()
defer func() {
cost := utils.TimeSinceInMilliSeconds(begin)
metrics.QueryMethodDurationMilliSeconds.WithLabelValues("GetContainerEventsData").Observe(cost)
}()
util := interutils.Util{
Storage: handler.storage,
}
util.GetUid(podYamls, key, &value)

if err := handler.storage.QueryLifePhaseWithPodUid(&podLifephases, value); err != nil {
return http.StatusOK, nil, fmt.Errorf("QueryLifePhaseWithPodUid error, error is %s", err)
}
Expand Down
16 changes: 16 additions & 0 deletions internal/grafanadi/handler/containerlifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"errors"
"fmt"
"net/http"
"time"

"github.com/alipay/container-observability-service/internal/grafanadi/service"
interutils "github.com/alipay/container-observability-service/internal/grafanadi/utils"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/data_access"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/model"
storagemodel "github.com/alipay/container-observability-service/pkg/dal/storage-client/model"
"github.com/alipay/container-observability-service/pkg/metrics"
"github.com/alipay/container-observability-service/pkg/utils"
)

Expand All @@ -19,11 +23,23 @@ type ContainerlifecycleHandler struct {
}

func (handler *ContainerlifecycleHandler) GetContainerLifecycleData(key, value string) (int, interface{}, error) {
podYamls := make([]*model.PodYaml, 0)
lifephases := make([]*storagemodel.LifePhase, 0)
slolist := make([]*storagemodel.SloTraceData, 0)
if len(value) == 0 {
return 0, nil, nil
}
begin := time.Now()
defer func() {
cost := utils.TimeSinceInMilliSeconds(begin)
metrics.QueryMethodDurationMilliSeconds.WithLabelValues("GetContainerLifecycleData").Observe(cost)
}()

util := interutils.Util{
Storage: handler.storage,
}
util.GetUid(podYamls, key, &value)

if err := handler.storage.QueryLifePhaseWithPodUid(&lifephases, value); err != nil {
return http.StatusOK, nil, fmt.Errorf("QueryLifePhaseWithPodUid error, error is %s", err)
}
Expand Down
19 changes: 19 additions & 0 deletions internal/grafanadi/handler/containerstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"errors"
"fmt"
"net/http"
"time"

"github.com/alipay/container-observability-service/internal/grafanadi/service"
interutils "github.com/alipay/container-observability-service/internal/grafanadi/utils"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/data_access"
"github.com/alipay/container-observability-service/pkg/dal/storage-client/model"
storagemodel "github.com/alipay/container-observability-service/pkg/dal/storage-client/model"
"github.com/alipay/container-observability-service/pkg/metrics"
"github.com/alipay/container-observability-service/pkg/utils"
)

Expand All @@ -20,6 +24,21 @@ type ContainerStatusHandler struct {

func (handler *ContainerStatusHandler) GetContainerStatusData(key, value string) (int, interface{}, error) {
slolist := make([]*storagemodel.SloTraceData, 0)
podYamls := make([]*model.PodYaml, 0)
if value == "" {
return http.StatusOK, nil, nil
}

begin := time.Now()
defer func() {
cost := utils.TimeSinceInMilliSeconds(begin)
metrics.QueryMethodDurationMilliSeconds.WithLabelValues("GetContainerStatusData").Observe(cost)
}()
util := interutils.Util{
Storage: handler.storage,
}
util.GetUid(podYamls, key, &value)

if err := handler.storage.QuerySloTraceDataWithPodUID(&slolist, value); err != nil {
return http.StatusOK, nil, fmt.Errorf("QuerySloTraceDataWithPodUID error, error is %s", err)
}
Expand Down
Loading

0 comments on commit 1eb8fb4

Please sign in to comment.