Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #5 from heartbeatsjp/add-filter-option
Browse files Browse the repository at this point in the history
add filter option
  • Loading branch information
k0f1sh authored Nov 10, 2022
2 parents 60608e7 + 27fbaaa commit bd38e08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ azure.Microsoft.ComputevirtualMachines.<resouce group>.<resource name>.DiskReadB
- Set the end time as unix timestamp, relative from now if 0 or negative value given (default 0)
- `interval-sec`
- Set the interval seconds (supported ones are: 60,300,900,1800,3600,21600,43200,86400. default 60)
- `filter`
- Set the filter

### Subcommands

#### check
Expand Down
5 changes: 2 additions & 3 deletions azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type FetchMetricDataInput struct {
startTime time.Time
endTime time.Time
interval int
filter string
}

// FetchMetricDefinitionsInput is input parameters for FetchMetricDefinitions
Expand All @@ -35,9 +36,6 @@ type FetchMetricDefinitionsInput struct {
resource string
resourceURI string
metricnamespace string
startTime time.Time
endTime time.Time
interval int
}

// Client is an API Client for Azure
Expand Down Expand Up @@ -159,6 +157,7 @@ func FetchMetricData(ctx context.Context, c *Client, params FetchMetricDataInput
aggregation: params.aggregation,
metricnames: m,
resultType: insights.Data,
filter: params.filter,
}
res, err := c.metricsList(ctx, input)
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func buildFetchMetricDataInput(c *cli.Context) FetchMetricDataInput {
startTime: convertToTime(c.GlobalInt64("start-time")),
endTime: convertToTime(c.GlobalInt64("end-time")),
interval: c.GlobalInt("interval-sec"),
filter: c.GlobalString("filter"),
}
}

Expand All @@ -49,9 +50,6 @@ func buildFetchMetricDefinitionsInput(c *cli.Context) FetchMetricDefinitionsInpu
resourceGroup: c.GlobalString("resource-group"),
namespace: c.GlobalString("namespace"),
resource: c.GlobalString("resource"),
startTime: convertToTime(c.GlobalInt64("start-time")),
endTime: convertToTime(c.GlobalInt64("end-time")),
interval: c.GlobalInt("interval-sec"),
}
}

Expand Down Expand Up @@ -155,6 +153,10 @@ func main() {
Usage: "interval second (supported ones are: 60,300,900,1800,3600,21600,43200,86400)",
Value: 60,
},
cli.StringFlag{
Name: "filter",
Usage: "Set the filter",
},
}

app.Before = appBefore
Expand Down

0 comments on commit bd38e08

Please sign in to comment.