You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/10/25 04:38:49 UTC

[GitHub] [skywalking-cli] mrproliu opened a new pull request #127: Support query list alarms

mrproliu opened a new pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127


   Resolve https://github.com/apache/skywalking/issues/7980


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-cli] wu-sheng merged pull request #127: Support query list alarms

Posted by GitBox <gi...@apache.org>.
wu-sheng merged pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-cli] codecov-commenter commented on pull request #127: Support query list alarms

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127#issuecomment-950528069


   # [Codecov](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#127](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6716306) into [master](https://codecov.io/gh/apache/skywalking-cli/commit/d2f1cff71f3ea9f325ff1c0d99dd0c40a35e527c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d2f1cff) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/skywalking-cli/pull/127/graphs/tree.svg?width=650&height=150&src=pr&token=oivudZDTNJ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@           Coverage Diff           @@
   ##           master     #127   +/-   ##
   =======================================
     Coverage   28.00%   28.00%           
   =======================================
     Files          20       20           
     Lines         400      400           
   =======================================
     Hits          112      112           
     Misses        280      280           
     Partials        8        8           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [d2f1cff...6716306](https://codecov.io/gh/apache/skywalking-cli/pull/127?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-cli] wu-sheng commented on pull request #127: Support query list alarms

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127#issuecomment-950555190


   FYI @wankai123 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-cli] wu-sheng commented on a change in pull request #127: Support query list alarms

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on a change in pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127#discussion_r735254347



##########
File path: internal/commands/alarm/list.go
##########
@@ -0,0 +1,120 @@
+// 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 alarm
+
+import (
+	"strings"
+
+	"github.com/urfave/cli/v2"
+
+	"github.com/apache/skywalking-cli/internal/commands/interceptor"
+	"github.com/apache/skywalking-cli/internal/flags"
+	"github.com/apache/skywalking-cli/internal/model"
+	"github.com/apache/skywalking-cli/pkg/display"
+	"github.com/apache/skywalking-cli/pkg/display/displayable"
+	"github.com/apache/skywalking-cli/pkg/graphql/alarm"
+
+	api "skywalking.apache.org/repo/goapi/query"
+)
+
+const DefaultPageSize = 15
+
+var listCommand = &cli.Command{
+	Name:    "list",
+	Aliases: []string{"ls"},
+	Usage:   "List alarms",
+	UsageText: `List alarms
+
+Examples:
+1. List all alarms:
+$ swctl alarm list
+`,
+	Flags: flags.Flags(
+		flags.DurationFlags,
+		[]cli.Flag{
+			&cli.StringFlag{
+				Name:     "keyword",
+				Usage:    "alarm keyword",
+				Required: false,
+			},
+			&cli.StringFlag{
+				Name:     "tags",
+				Usage:    "`tags` of the alarm, in form of `key=value,key=value`",
+				Required: false,
+			},
+			&cli.GenericFlag{
+				Name:  "scope",
+				Usage: "the `scope` of the alarm entity",
+				Value: &model.ScopeEnumValue{
+					Enum:     api.AllScope,
+					Default:  "",
+					Selected: "",
+				},
+			},
+		},
+	),
+	Before: interceptor.BeforeChain(
+		interceptor.DurationInterceptor,
+	),
+	Action: func(ctx *cli.Context) error {
+		start := ctx.String("start")
+		end := ctx.String("end")
+		step := ctx.Generic("step")
+
+		keyword := ctx.String("keyword")
+		tagStr := ctx.String("tags")
+		scope := ctx.Generic("scope").(*model.ScopeEnumValue).Selected
+
+		duration := api.Duration{
+			Start: start,
+			End:   end,
+			Step:  step.(*model.StepEnumValue).Selected,
+		}
+
+		var tags []*api.AlarmTag
+		if tagStr != "" {
+			tagArr := strings.Split(tagStr, ",")
+			for _, tag := range tagArr {
+				kv := strings.Split(tag, "=")

Review comment:
       key wouldn't include =, but value could. Please use split 2 only.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [skywalking-cli] kezhenxu94 commented on a change in pull request #127: Support query list alarms

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #127:
URL: https://github.com/apache/skywalking-cli/pull/127#discussion_r735253661



##########
File path: internal/commands/alarm/list.go
##########
@@ -0,0 +1,120 @@
+// 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 alarm
+
+import (
+	"strings"
+
+	"github.com/urfave/cli/v2"
+
+	"github.com/apache/skywalking-cli/internal/commands/interceptor"
+	"github.com/apache/skywalking-cli/internal/flags"
+	"github.com/apache/skywalking-cli/internal/model"
+	"github.com/apache/skywalking-cli/pkg/display"
+	"github.com/apache/skywalking-cli/pkg/display/displayable"
+	"github.com/apache/skywalking-cli/pkg/graphql/alarm"
+
+	api "skywalking.apache.org/repo/goapi/query"
+)
+
+const DefaultPageSize = 15
+
+var listCommand = &cli.Command{
+	Name:    "list",
+	Aliases: []string{"ls"},
+	Usage:   "List alarms",
+	UsageText: `List alarms
+
+Examples:
+1. List all alarms:
+$ swctl alarm list
+`,
+	Flags: flags.Flags(
+		flags.DurationFlags,
+		[]cli.Flag{
+			&cli.StringFlag{
+				Name:     "keyword",
+				Usage:    "alarm keyword",
+				Required: false,
+			},
+			&cli.StringFlag{
+				Name:     "tags",
+				Usage:    "`tags` of the alarm, in form of `key=value,key=value`",
+				Required: false,
+			},
+			&cli.GenericFlag{
+				Name:  "scope",
+				Usage: "the `scope` of the alarm entity",
+				Value: &model.ScopeEnumValue{
+					Enum:     api.AllScope,
+					Default:  "",
+					Selected: "",
+				},
+			},
+		},
+	),
+	Before: interceptor.BeforeChain(
+		interceptor.DurationInterceptor,
+	),
+	Action: func(ctx *cli.Context) error {
+		start := ctx.String("start")
+		end := ctx.String("end")
+		step := ctx.Generic("step")
+
+		keyword := ctx.String("keyword")
+		tagStr := ctx.String("tags")
+		scope := ctx.Generic("scope").(*model.ScopeEnumValue).Selected
+
+		duration := api.Duration{
+			Start: start,
+			End:   end,
+			Step:  step.(*model.StepEnumValue).Selected,
+		}
+
+		var tags []*api.AlarmTag
+		if tagStr != "" {
+			tagArr := strings.Split(tagStr, ",")
+			for _, tag := range tagArr {
+				kv := strings.Split(tag, "=")

Review comment:
       Add a condition `len(kv) == 2` otherwise should fail fast




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org