Skip to content

Commit

Permalink
update flag to .filters
Browse files Browse the repository at this point in the history
  • Loading branch information
vrunoa committed Feb 2, 2022
1 parent b51d994 commit 1a5d921
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions collectors/monitoring_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ var (
).Envar("STACKDRIVER_EXPORTER_DROP_DELEGATED_PROJECTS").Default("false").Bool()

monitoringMetricsExtraFilter = kingpin.Flag(
"monitoring.metrics-extra-filter", "Extra filters. i.e: pubsub.googleapis.com/subscription:resource.labels.subscription_id=monitoring.regex.full_match(\"my-subs-prefix.*\")").Strings()
"monitoring.filters", "Filters. i.e: pubsub.googleapis.com/subscription:resource.labels.subscription_id=monitoring.regex.full_match(\"my-subs-prefix.*\")").Strings()
)

type MetricExtraFilter struct {
type MetricFilter struct {
Prefix string
Modifier string
}

type MonitoringCollector struct {
projectID string
metricsTypePrefixes []string
metricsExtraFilters []MetricExtraFilter
metricsFilters []MetricFilter
metricsInterval time.Duration
metricsOffset time.Duration
monitoringService *monitoring.Service
Expand Down Expand Up @@ -154,11 +154,11 @@ func NewMonitoringCollector(projectID string, monitoringService *monitoring.Serv
}
}
}
var extraFilters []MetricExtraFilter
var extraFilters []MetricFilter
for _, ef := range *monitoringMetricsExtraFilter {
efPrefix, efModifier := utils.GetExtraFilterModifiers(ef, ":")
if efPrefix != "" {
extraFilter := MetricExtraFilter{
extraFilter := MetricFilter{
Prefix: efPrefix,
Modifier: efModifier,
}
Expand All @@ -169,7 +169,7 @@ func NewMonitoringCollector(projectID string, monitoringService *monitoring.Serv
monitoringCollector := &MonitoringCollector{
projectID: projectID,
metricsTypePrefixes: filteredPrefixes,
metricsExtraFilters: extraFilters,
metricsFilters: extraFilters,
metricsInterval: *monitoringMetricsInterval,
metricsOffset: *monitoringMetricsOffset,
monitoringService: monitoringService,
Expand Down Expand Up @@ -259,7 +259,7 @@ func (c *MonitoringCollector) reportMonitoringMetrics(ch chan<- prometheus.Metri
c.projectID,
metricDescriptor.Type)
}
for _, ef := range c.metricsExtraFilters {
for _, ef := range c.metricsFilters {
if strings.Contains(metricDescriptor.Type, ef.Prefix) {
filter = fmt.Sprintf("%s AND (%s)", filter, ef.Modifier)
}
Expand Down

0 comments on commit 1a5d921

Please sign in to comment.