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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new 838e222  Support continuous profiling related command (#173)
838e222 is described below

commit 838e222da5ab81b383c5bc8526e5d30002d836f9
Author: mrproliu <741550...@qq.com>
AuthorDate: Fri Mar 3 08:00:30 2023 +0800

    Support continuous profiling related command (#173)
---
 CHANGES.md                                         |   2 +
 ...QueryContinuousProfilingServiceTargets.graphql} |  20 +--
 .../SetContinuousProfilingPolicy.graphql}          |  15 +-
 .../ebpf/QueryEBPFProfilingTaskList.graphql        |  13 +-
 dist/LICENSE                                       |  10 +-
 examples/continuous-profiling.yaml                 |  51 +++++++
 go.mod                                             |  10 +-
 go.sum                                             |  27 ++--
 .../metrics/linear/multiple-linear-metrics.go      |   2 +-
 .../{profiling.go => continuous/continuous.go}     |  19 +--
 .../profiling/{ebpf => continuous}/list.go         |  16 +-
 internal/commands/profiling/continuous/set.go      | 163 +++++++++++++++++++++
 internal/commands/profiling/ebpf/list.go           |  16 +-
 internal/commands/profiling/profiling.go           |   2 +
 .../ebpf/profilingTriggerType.go}                  |  40 +++--
 pkg/graphql/profiling/continuous.go                |  51 +++++++
 pkg/graphql/profiling/ebpf.go                      |   3 +-
 pkg/graphql/utils/parser.go                        |   6 +-
 pkg/graphql/utils/parser_test.go                   |   2 +-
 19 files changed, 385 insertions(+), 83 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index fea6fa6..1643045 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -34,6 +34,8 @@ Release Notes.
 * Add the sub-command `records list` for adapt the new record query API by 
@mrproliu in https://github.com/apache/skywalking-cli/pull/167
 * Add the attached events fields into the `trace` sub-command by @mrproliu in 
https://github.com/apache/skywalking-cli/pull/169
 * Add the sampling config file into the `profiling ebpf create network` 
sub-command by @mrproliu in https://github.com/apache/skywalking-cli/pull/171
+* Add the sub-command `profiling continuous` for adapt the new continuous 
profiling API by @mrproliu in https://github.com/apache/skywalking-cli/pull/173
+* Adapt the sub-command `metrics` for deprecate scope fron entity by @mrproliu 
in https://github.com/apache/skywalking-cli/pull/173
 
 0.10.0
 ------------------
diff --git a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql 
b/assets/graphqls/profiling/continuous/QueryContinuousProfilingServiceTargets.graphql
similarity index 77%
copy from assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
copy to 
assets/graphqls/profiling/continuous/QueryContinuousProfilingServiceTargets.graphql
index 2f72a78..ee1def3 100644
--- a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
+++ 
b/assets/graphqls/profiling/continuous/QueryContinuousProfilingServiceTargets.graphql
@@ -16,15 +16,15 @@
 # under the License.
 
 query ($serviceId: ID!){
-    result: queryEBPFProfilingTasks(serviceId: $serviceId) {
-        taskId
-        serviceId
-        serviceName
-        processLabels
-        taskStartTime
-        triggerType
-        fixedTriggerDuration
-        targetType
-        createTime
+    result: queryContinuousProfilingServiceTargets(serviceId: $serviceId) {
+        type
+        checkItems {
+            type
+            threshold
+            period
+            count
+            uriList
+            uriRegex
+        }
     }
 }
\ No newline at end of file
diff --git a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql 
b/assets/graphqls/profiling/continuous/SetContinuousProfilingPolicy.graphql
similarity index 74%
copy from assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
copy to 
assets/graphqls/profiling/continuous/SetContinuousProfilingPolicy.graphql
index 2f72a78..9be7236 100644
--- a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
+++ b/assets/graphqls/profiling/continuous/SetContinuousProfilingPolicy.graphql
@@ -15,16 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.
 
-query ($serviceId: ID!){
-    result: queryEBPFProfilingTasks(serviceId: $serviceId) {
-        taskId
-        serviceId
-        serviceName
-        processLabels
-        taskStartTime
-        triggerType
-        fixedTriggerDuration
-        targetType
-        createTime
+mutation ($request: ContinuousProfilingPolicyCreation!){
+    result: setContinuousProfilingPolicy(request: $request) {
+        status
+        errorReason
     }
 }
\ No newline at end of file
diff --git a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql 
b/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
index 2f72a78..cbb8589 100644
--- a/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
+++ b/assets/graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql
@@ -15,15 +15,24 @@
 # specific language governing permissions and limitations
 # under the License.
 
-query ($serviceId: ID!){
-    result: queryEBPFProfilingTasks(serviceId: $serviceId) {
+query ($serviceId: ID!, $triggerType: EBPFProfilingTriggerType){
+    result: queryEBPFProfilingTasks(serviceId: $serviceId, triggerType: 
$triggerType) {
         taskId
         serviceId
         serviceName
+        serviceInstanceId
+        serviceInstanceName
         processLabels
+        processId
+        processName
         taskStartTime
         triggerType
         fixedTriggerDuration
+        continuousProfilingCauses {
+            type
+            singleValue {threshold current}
+            uri {uriRegex uriPath threshold current}
+        }
         targetType
         createTime
     }
diff --git a/dist/LICENSE b/dist/LICENSE
index a9a7c66..64ef910 100644
--- a/dist/LICENSE
+++ b/dist/LICENSE
@@ -213,7 +213,7 @@ The text of each license is also included at 
licenses/license-[project].txt.
     k8s.io/utils v0.0.0-20210802155522-efc7438f0176 Apache-2.0
     sigs.k8s.io/controller-runtime v0.10.0 Apache-2.0
     sigs.k8s.io/structured-merge-diff/v4 v4.1.2 Apache-2.0
-    skywalking.apache.org/repo/goapi v0.0.0-20221123034834-51b3101f6c9f 
Apache-2.0
+    skywalking.apache.org/repo/goapi v0.0.0-20230301143132-aa3f8469385b 
Apache-2.0
 
 ========================================================================
 BSD-2-Clause licenses
@@ -244,11 +244,11 @@ The text of each license is also included at 
licenses/license-[project].txt.
     github.com/imdario/mergo v0.3.12 BSD-3-Clause
     github.com/spf13/pflag v1.0.5 BSD-3-Clause
     golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 BSD-3-Clause
-    golang.org/x/net v0.0.0-20220909164309-bea034e7d591 BSD-3-Clause
+    golang.org/x/net v0.6.0 BSD-3-Clause
     golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d BSD-3-Clause
-    golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab BSD-3-Clause
-    golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 BSD-3-Clause
-    golang.org/x/text v0.4.0 BSD-3-Clause
+    golang.org/x/sys v0.5.0 BSD-3-Clause
+    golang.org/x/term v0.5.0 BSD-3-Clause
+    golang.org/x/text v0.7.0 BSD-3-Clause
     golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac BSD-3-Clause
     google.golang.org/protobuf v1.28.1 BSD-3-Clause
     gopkg.in/inf.v0 v0.9.1 BSD-3-Clause
diff --git a/examples/continuous-profiling.yaml 
b/examples/continuous-profiling.yaml
new file mode 100644
index 0000000..006ae82
--- /dev/null
+++ b/examples/continuous-profiling.yaml
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Policy config
+# policy: the policy config list
+# - type: the profiling target type when reached the threshold, support: 
"ON_CPU", "OFF_CPU", "NETWORK"
+#   checks: define the thresholds, when any configuration item reaches the 
threshold, it will trigger profiling task
+#     - type: monitoring type, please see the below monitoring type with 
threshold description
+#       threshold: monitor threshold, please see the below monitoring type 
with threshold description
+#       period: the length of time to evaluate the metrics
+#       count: how many times after the metrics match the threshold, will 
trigger profiling
+#       uriList: the URI paths filter when monitor the HTTP related types
+#       uriRegex: the URI regex filter when monitor the HTTP related types
+
+# Monitoring type with threshold
+# PROCESS_CPU: Monitoring Process CPU percent, threshold value in [0-100]
+# PROCESS_THREAD_COUNT: Monitoring process thread count, threshold value must 
bigger than zero
+# SYSTEM_LOAD: Monitoring current system load, threshold value must bigger 
than zero
+# HTTP_ERROR_RATE: Monitoring the process HTTP response error(status>=500) 
percent, threshold value in [0-100]
+# HTTP_AVG_RESPONSE_TIME: Monitoring the process HTTP response duration(ms), 
threshold value must be bigger than zero
+
+policy:
+  - type: ON_CPU
+    checkers:
+      - type: PROCESS_CPU
+        threshold: 1
+        period: 10
+        count: 3
+      - type: PROCESS_THREAD_COUNT
+        threshold: 30
+        period: 10
+        count: 1
+  - type: NETWORK
+    checkers:
+      - type: HTTP_ERROR_RATE
+        threshold: 1
+        period: 10
+        count: 1
\ No newline at end of file
diff --git a/go.mod b/go.mod
index a86f33f..faffb39 100644
--- a/go.mod
+++ b/go.mod
@@ -15,12 +15,12 @@ require (
        github.com/sirupsen/logrus v1.8.1
        github.com/spf13/viper v1.7.0
        github.com/urfave/cli/v2 v2.3.0
-       golang.org/x/text v0.4.0
+       golang.org/x/text v0.7.0
        google.golang.org/grpc v1.40.0
        gopkg.in/yaml.v2 v2.4.0
        k8s.io/apimachinery v0.22.1
        sigs.k8s.io/controller-runtime v0.10.0
-       skywalking.apache.org/repo/goapi v0.0.0-20221123034834-51b3101f6c9f
+       skywalking.apache.org/repo/goapi v0.0.0-20230301143132-aa3f8469385b
 )
 
 require (
@@ -69,10 +69,10 @@ require (
        github.com/spf13/pflag v1.0.5 // indirect
        github.com/subosito/gotenv v1.2.0 // indirect
        golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
-       golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
+       golang.org/x/net v0.6.0 // indirect
        golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
-       golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
-       golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
+       golang.org/x/sys v0.5.0 // indirect
+       golang.org/x/term v0.5.0 // indirect
        golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
        gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
        google.golang.org/appengine v1.6.7 // indirect
diff --git a/go.sum b/go.sum
index 5204896..8584b61 100644
--- a/go.sum
+++ b/go.sum
@@ -456,6 +456,7 @@ github.com/xiang90/probing 
v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
 github.com/yuin/goldmark v1.1.27/go.mod 
h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.2.1/go.mod 
h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
 github.com/yuin/goldmark v1.3.5/go.mod 
h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+github.com/yuin/goldmark v1.4.13/go.mod 
h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4=
 go.etcd.io/etcd/api/v3 v3.5.0/go.mod 
h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
@@ -503,6 +504,7 @@ golang.org/x/crypto 
v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPh
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod 
h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod 
h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod 
h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod 
h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 
h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
 golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod 
h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod 
h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -538,6 +540,7 @@ golang.org/x/mod 
v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB
 golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod 
h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod 
h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -568,12 +571,13 @@ golang.org/x/net 
v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R
 golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod 
h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
 golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod 
h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
 golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod 
h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod 
h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod 
h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
 golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod 
h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
 golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod 
h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod 
h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
-golang.org/x/net v0.0.0-20220909164309-bea034e7d591 
h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI=
-golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod 
h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
+golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod 
h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod 
h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod 
h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -589,6 +593,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod 
h1:RxMgew5VJxzue5/jJ
 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod 
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod 
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod 
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod 
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
 golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod 
h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod 
h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod 
h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -639,14 +644,15 @@ golang.org/x/sys 
v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab 
h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
-golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod 
h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod 
h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod 
h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod 
h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod 
h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 
h1:EH1Deb8WZJ0xc0WK//leUHXcX9aLE5SymusoTmMZye8=
-golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod 
h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
+golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod 
h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod 
h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -655,8 +661,8 @@ golang.org/x/text v0.3.3/go.mod 
h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
-golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod 
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod 
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod 
h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -706,6 +712,7 @@ golang.org/x/tools 
v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
 golang.org/x/tools v0.1.2/go.mod 
h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/tools v0.1.3/go.mod 
h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
+golang.org/x/tools v0.1.12/go.mod 
h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -857,5 +864,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2 
h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3
 sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod 
h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
 sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
 sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
-skywalking.apache.org/repo/goapi v0.0.0-20221123034834-51b3101f6c9f 
h1:iRQHKYsca0gbSxGWFjlkQ/WIuLyKReFUk2PscgzBqAw=
-skywalking.apache.org/repo/goapi v0.0.0-20221123034834-51b3101f6c9f/go.mod 
h1:lxmYWY1uAP5SLVKNymAyDzn7KG6dhPWN+pYHmyt+0vo=
+skywalking.apache.org/repo/goapi v0.0.0-20230301143132-aa3f8469385b 
h1:VAWQr1mJk4P/a8VZ9UASY8H53wj0zdLHgYvhddyQcXw=
+skywalking.apache.org/repo/goapi v0.0.0-20230301143132-aa3f8469385b/go.mod 
h1:WovoDv1GA+8VuvHPVJL7q/fL0KlYPBZq5rTMCFQRzJU=
diff --git a/internal/commands/metrics/linear/multiple-linear-metrics.go 
b/internal/commands/metrics/linear/multiple-linear-metrics.go
index 3ffd1eb..c94c1b8 100644
--- a/internal/commands/metrics/linear/multiple-linear-metrics.go
+++ b/internal/commands/metrics/linear/multiple-linear-metrics.go
@@ -103,7 +103,7 @@ $ swctl metrics multiple-linear --name all_percentile 
--labels=0,1,2,3,4 --relab
                        return err
                }
 
-               if *entity.ServiceName == "" && entity.Scope != api.ScopeAll {
+               if *entity.ServiceName == "" && *entity.Scope != api.ScopeAll {
                        return fmt.Errorf("the name of service should be 
specified when metrics' scope is not `All`")
                }
 
diff --git a/internal/commands/profiling/profiling.go 
b/internal/commands/profiling/continuous/continuous.go
similarity index 67%
copy from internal/commands/profiling/profiling.go
copy to internal/commands/profiling/continuous/continuous.go
index 2a6cb5a..7e7d969 100644
--- a/internal/commands/profiling/profiling.go
+++ b/internal/commands/profiling/continuous/continuous.go
@@ -15,22 +15,15 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package profiling
+package continuous
 
-import (
-       "github.com/urfave/cli/v2"
-
-       "github.com/apache/skywalking-cli/internal/commands/profiling/ebpf"
-       "github.com/apache/skywalking-cli/internal/commands/profiling/trace"
-)
+import "github.com/urfave/cli/v2"
 
 var Command = &cli.Command{
-       Name:  "profiling",
-       Usage: "profiling related sub-command",
-       UsageText: `If your application has performance issue, you could try to 
profiling. 
-Please following sub-command to get more information.`,
+       Name:  "continuous",
+       Usage: "Continuous Profiling related sub-command",
        Subcommands: []*cli.Command{
-               trace.Command,
-               ebpf.Command,
+               SetPolicyCommand,
+               ListCommand,
        },
 }
diff --git a/internal/commands/profiling/ebpf/list.go 
b/internal/commands/profiling/continuous/list.go
similarity index 74%
copy from internal/commands/profiling/ebpf/list.go
copy to internal/commands/profiling/continuous/list.go
index ca34838..7790638 100644
--- a/internal/commands/profiling/ebpf/list.go
+++ b/internal/commands/profiling/continuous/list.go
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package ebpf
+package continuous
 
 import (
        "github.com/urfave/cli/v2"
@@ -27,15 +27,15 @@ import (
        "github.com/apache/skywalking-cli/pkg/graphql/profiling"
 )
 
-var ListTaskCommand = &cli.Command{
+var ListCommand = &cli.Command{
        Name:    "list",
        Aliases: []string{"ls"},
-       Usage:   `query ebpf profiling task list`,
-       UsageText: `This command lists all ebpf profiling task, via id or name 
in service, instance or process.
+       Usage:   `query service continuous profiling policy`,
+       UsageText: `This command lists all service continuous profiling policy, 
via id or name in service.
 
 Example:
-1. Query profiling tasks of service "business-zone::projectC"
-$ swctl profiling ebpf list --service-name=service-name
+1. Query continuous profiling policy of service "business-zone::projectC"
+$ swctl profiling continuous list --service-name=business-zone::projectC
 `,
        Flags: flags.Flags(
                flags.ServiceFlags,
@@ -46,11 +46,11 @@ $ swctl profiling ebpf list --service-name=service-name
        Action: func(ctx *cli.Context) error {
                serviceID := ctx.String("service-id")
 
-               processes, err := profiling.QueryEBPFProfilingTaskList(ctx, 
serviceID)
+               result, err := 
profiling.QueryContinuousProfilingServiceTargets(ctx, serviceID)
                if err != nil {
                        return err
                }
 
-               return display.Display(ctx, &displayable.Displayable{Data: 
processes})
+               return display.Display(ctx, &displayable.Displayable{Data: 
result})
        },
 }
diff --git a/internal/commands/profiling/continuous/set.go 
b/internal/commands/profiling/continuous/set.go
new file mode 100644
index 0000000..7299130
--- /dev/null
+++ b/internal/commands/profiling/continuous/set.go
@@ -0,0 +1,163 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package continuous
+
+import (
+       "fmt"
+       "os"
+
+       "github.com/apache/skywalking-cli/internal/commands/interceptor"
+       "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/pkg/display"
+       "github.com/apache/skywalking-cli/pkg/display/displayable"
+       "github.com/apache/skywalking-cli/pkg/graphql/profiling"
+
+       "github.com/urfave/cli/v2"
+
+       "gopkg.in/yaml.v2"
+
+       api "skywalking.apache.org/repo/goapi/query"
+)
+
+type PolicyConfig struct {
+       Policies []*PolicyTarget `yaml:"policy"`
+}
+
+type PolicyTarget struct {
+       Type     string        `yaml:"type"`
+       Checkers []*PolicyItem `yaml:"checkers"`
+}
+
+type PolicyItem struct {
+       Type      string   `yaml:"type"`
+       Threshold string   `yaml:"threshold"`
+       Period    int      `yaml:"period"`
+       Count     int      `yaml:"count"`
+       URIList   []string `yaml:"uriList"`
+       URIRegex  string   `yaml:"uriRegex"`
+}
+
+var SetPolicyCommand = &cli.Command{
+       Name:    "set",
+       Aliases: []string{"s"},
+       Usage:   "Set the continuous profiling policy to service",
+       UsageText: `Set the continuous profiling policy to service
+
+Examples:
+1. Set the service continuous profiling policy
+$ swctl profiling continuous set --service-name=abc 
--config=/path/to/config.yaml`,
+       Flags: flags.Flags(
+               flags.ServiceFlags,
+               []cli.Flag{
+                       &cli.StringFlag{
+                               Name:     "config",
+                               Usage:    "the `config` file define the service 
policy configuration, if not provide then make the service policy is empty",
+                               Required: false,
+                       },
+               },
+       ),
+       Before: interceptor.BeforeChain(
+               interceptor.ParseService(true),
+       ),
+       Action: func(ctx *cli.Context) error {
+               serviceID := ctx.String("service-id")
+
+               configFile := ctx.String("config")
+
+               targets := make([]*api.ContinuousProfilingPolicyTargetCreation, 
0)
+               if configFile != "" {
+                       config, err := os.ReadFile(configFile)
+                       if err != nil {
+                               return err
+                       }
+                       r := &PolicyConfig{}
+                       if e := yaml.Unmarshal(config, r); e != nil {
+                               return err
+                       }
+
+                       targets, err = parsingPolicyConfig(r)
+                       if err != nil {
+                               return err
+                       }
+               }
+
+               request := &api.ContinuousProfilingPolicyCreation{
+                       ServiceID: serviceID,
+                       Targets:   targets,
+               }
+
+               result, err := profiling.SetContinuousProfilingPolicy(ctx, 
request)
+               if err != nil {
+                       return err
+               }
+
+               return display.Display(ctx, &displayable.Displayable{Data: 
result, Condition: request})
+       },
+}
+
+func parsingPolicyConfig(conf *PolicyConfig) 
([]*api.ContinuousProfilingPolicyTargetCreation, error) {
+       result := make([]*api.ContinuousProfilingPolicyTargetCreation, 0)
+       if len(conf.Policies) == 0 {
+               return result, nil
+       }
+       for _, t := range conf.Policies {
+               var realTarget api.ContinuousProfilingTargetType
+               for _, targetType := range api.AllContinuousProfilingTargetType 
{
+                       if t.Type == targetType.String() {
+                               realTarget = targetType
+                               break
+                       }
+               }
+               if realTarget == "" {
+                       return nil, fmt.Errorf("cannot found the target: %s", 
t.Type)
+               }
+
+               target := &api.ContinuousProfilingPolicyTargetCreation{
+                       TargetType: realTarget,
+               }
+               for _, c := range t.Checkers {
+                       var realMonitorType api.ContinuousProfilingMonitorType
+                       for _, monitorType := range 
api.AllContinuousProfilingMonitorType {
+                               if c.Type == monitorType.String() {
+                                       realMonitorType = monitorType
+                                       break
+                               }
+                       }
+                       if realMonitorType == "" {
+                               return nil, fmt.Errorf("cannot fount the 
monitor type: %s", c.Type)
+                       }
+
+                       item := &api.ContinuousProfilingPolicyItemCreation{
+                               Type:      realMonitorType,
+                               Threshold: c.Threshold,
+                               Period:    c.Period,
+                               Count:     c.Count,
+                               URIList:   c.URIList,
+                       }
+
+                       if c.URIRegex != "" {
+                               item.URIRegex = &c.URIRegex
+                       }
+
+                       target.CheckItems = append(target.CheckItems, item)
+               }
+
+               result = append(result, target)
+       }
+       return result, nil
+}
diff --git a/internal/commands/profiling/ebpf/list.go 
b/internal/commands/profiling/ebpf/list.go
index ca34838..35dcd4f 100644
--- a/internal/commands/profiling/ebpf/list.go
+++ b/internal/commands/profiling/ebpf/list.go
@@ -20,8 +20,11 @@ package ebpf
 import (
        "github.com/urfave/cli/v2"
 
+       api "skywalking.apache.org/repo/goapi/query"
+
        "github.com/apache/skywalking-cli/internal/commands/interceptor"
        "github.com/apache/skywalking-cli/internal/flags"
+       "github.com/apache/skywalking-cli/internal/model/ebpf"
        "github.com/apache/skywalking-cli/pkg/display"
        "github.com/apache/skywalking-cli/pkg/display/displayable"
        "github.com/apache/skywalking-cli/pkg/graphql/profiling"
@@ -39,6 +42,17 @@ $ swctl profiling ebpf list --service-name=service-name
 `,
        Flags: flags.Flags(
                flags.ServiceFlags,
+               []cli.Flag{
+                       &cli.GenericFlag{
+                               Name:  "trigger",
+                               Usage: "the trigger type for the profiling 
task",
+                               Value: &ebpf.ProfilingTriggerTypeEnumValue{
+                                       Enum:     
api.AllEBPFProfilingTriggerType,
+                                       Default:  
api.EBPFProfilingTriggerTypeFixedTime,
+                                       Selected: 
api.EBPFProfilingTriggerTypeFixedTime,
+                               },
+                       },
+               },
        ),
        Before: interceptor.BeforeChain(
                interceptor.ParseService(true),
@@ -46,7 +60,7 @@ $ swctl profiling ebpf list --service-name=service-name
        Action: func(ctx *cli.Context) error {
                serviceID := ctx.String("service-id")
 
-               processes, err := profiling.QueryEBPFProfilingTaskList(ctx, 
serviceID)
+               processes, err := profiling.QueryEBPFProfilingTaskList(ctx, 
serviceID, 
ctx.Generic("trigger").(*ebpf.ProfilingTriggerTypeEnumValue).Selected)
                if err != nil {
                        return err
                }
diff --git a/internal/commands/profiling/profiling.go 
b/internal/commands/profiling/profiling.go
index 2a6cb5a..6059b76 100644
--- a/internal/commands/profiling/profiling.go
+++ b/internal/commands/profiling/profiling.go
@@ -20,6 +20,7 @@ package profiling
 import (
        "github.com/urfave/cli/v2"
 
+       
"github.com/apache/skywalking-cli/internal/commands/profiling/continuous"
        "github.com/apache/skywalking-cli/internal/commands/profiling/ebpf"
        "github.com/apache/skywalking-cli/internal/commands/profiling/trace"
 )
@@ -32,5 +33,6 @@ Please following sub-command to get more information.`,
        Subcommands: []*cli.Command{
                trace.Command,
                ebpf.Command,
+               continuous.Command,
        },
 }
diff --git a/internal/commands/profiling/profiling.go 
b/internal/model/ebpf/profilingTriggerType.go
similarity index 51%
copy from internal/commands/profiling/profiling.go
copy to internal/model/ebpf/profilingTriggerType.go
index 2a6cb5a..740f71a 100644
--- a/internal/commands/profiling/profiling.go
+++ b/internal/model/ebpf/profilingTriggerType.go
@@ -15,22 +15,36 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package profiling
+package ebpf
 
 import (
-       "github.com/urfave/cli/v2"
+       "fmt"
+       "strings"
 
-       "github.com/apache/skywalking-cli/internal/commands/profiling/ebpf"
-       "github.com/apache/skywalking-cli/internal/commands/profiling/trace"
+       api "skywalking.apache.org/repo/goapi/query"
 )
 
-var Command = &cli.Command{
-       Name:  "profiling",
-       Usage: "profiling related sub-command",
-       UsageText: `If your application has performance issue, you could try to 
profiling. 
-Please following sub-command to get more information.`,
-       Subcommands: []*cli.Command{
-               trace.Command,
-               ebpf.Command,
-       },
+type ProfilingTriggerTypeEnumValue struct {
+       Enum     []api.EBPFProfilingTriggerType
+       Default  api.EBPFProfilingTriggerType
+       Selected api.EBPFProfilingTriggerType
+}
+
+func (s *ProfilingTriggerTypeEnumValue) Set(value string) error {
+       for _, enum := range s.Enum {
+               if strings.EqualFold(enum.String(), value) {
+                       s.Selected = enum
+                       return nil
+               }
+       }
+       orders := make([]string, len(api.AllEBPFProfilingTargetType))
+       for i, order := range api.AllEBPFProfilingTargetType {
+               orders[i] = order.String()
+       }
+       return fmt.Errorf("allowed trigger type are %s", strings.Join(orders, 
", "))
+}
+
+// String representation of the order
+func (s ProfilingTriggerTypeEnumValue) String() string {
+       return s.Selected.String()
 }
diff --git a/pkg/graphql/profiling/continuous.go 
b/pkg/graphql/profiling/continuous.go
new file mode 100644
index 0000000..96b1785
--- /dev/null
+++ b/pkg/graphql/profiling/continuous.go
@@ -0,0 +1,51 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package profiling
+
+import (
+       "github.com/apache/skywalking-cli/assets"
+       "github.com/apache/skywalking-cli/pkg/graphql/client"
+
+       "github.com/machinebox/graphql"
+
+       "github.com/urfave/cli/v2"
+
+       api "skywalking.apache.org/repo/goapi/query"
+)
+
+func SetContinuousProfilingPolicy(ctx *cli.Context, creation 
*api.ContinuousProfilingPolicyCreation) (api.ContinuousProfilingSetResult, 
error) {
+       var response map[string]api.ContinuousProfilingSetResult
+
+       request := 
graphql.NewRequest(assets.Read("graphqls/profiling/continuous/SetContinuousProfilingPolicy.graphql"))
+       request.Var("request", creation)
+
+       err := client.ExecuteQuery(ctx, request, &response)
+
+       return response["result"], err
+}
+
+func QueryContinuousProfilingServiceTargets(ctx *cli.Context, serviceID 
string) ([]*api.ContinuousProfilingPolicyTarget, error) {
+       var response map[string][]*api.ContinuousProfilingPolicyTarget
+
+       request := 
graphql.NewRequest(assets.Read("graphqls/profiling/continuous/QueryContinuousProfilingServiceTargets.graphql"))
+       request.Var("serviceId", serviceID)
+
+       err := client.ExecuteQuery(ctx, request, &response)
+
+       return response["result"], err
+}
diff --git a/pkg/graphql/profiling/ebpf.go b/pkg/graphql/profiling/ebpf.go
index c75e392..0cdf3d4 100644
--- a/pkg/graphql/profiling/ebpf.go
+++ b/pkg/graphql/profiling/ebpf.go
@@ -62,11 +62,12 @@ func QueryPrepareCreateEBPFProfilingTaskData(ctx 
*cli.Context, serviceID string)
        return response["result"], err
 }
 
-func QueryEBPFProfilingTaskList(ctx *cli.Context, serviceID string) 
([]*api.EBPFProfilingTask, error) {
+func QueryEBPFProfilingTaskList(ctx *cli.Context, serviceID string, 
triggerType api.EBPFProfilingTriggerType) ([]*api.EBPFProfilingTask, error) {
        var response map[string][]*api.EBPFProfilingTask
 
        request := 
graphql.NewRequest(assets.Read("graphqls/profiling/ebpf/QueryEBPFProfilingTaskList.graphql"))
        request.Var("serviceId", serviceID)
+       request.Var("triggerType", triggerType)
 
        err := client.ExecuteQuery(ctx, request, &response)
 
diff --git a/pkg/graphql/utils/parser.go b/pkg/graphql/utils/parser.go
index 15925c5..dccfbde 100644
--- a/pkg/graphql/utils/parser.go
+++ b/pkg/graphql/utils/parser.go
@@ -24,7 +24,7 @@ import (
 )
 
 // ParseScope defines the scope based on the input parameters.
-func ParseScope(entity *api.Entity) api.Scope {
+func ParseScope(entity *api.Entity) *api.Scope {
        scope := api.ScopeAll
 
        if *entity.DestProcessName != "" {
@@ -37,13 +37,15 @@ func ParseScope(entity *api.Entity) api.Scope {
                scope = api.ScopeServiceRelation
        } else if *entity.EndpointName != "" {
                scope = api.ScopeEndpoint
+       } else if *entity.ProcessName != "" {
+               scope = api.ScopeProcess
        } else if *entity.ServiceInstanceName != "" {
                scope = api.ScopeServiceInstance
        } else if *entity.ServiceName != "" {
                scope = api.ScopeService
        }
 
-       return scope
+       return &scope
 }
 
 // ParseScopeInTop defines the scope based on the metrics' name.
diff --git a/pkg/graphql/utils/parser_test.go b/pkg/graphql/utils/parser_test.go
index 9adb020..4feee71 100644
--- a/pkg/graphql/utils/parser_test.go
+++ b/pkg/graphql/utils/parser_test.go
@@ -148,7 +148,7 @@ func TestParseScope(t *testing.T) {
 
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       if got := ParseScope(tt.args); got != tt.want {
+                       if got := ParseScope(tt.args); *got != tt.want {
                                t.Errorf("ParseScope() = %v, want %v", got, 
tt.want)
                        }
                })


Reply via email to