diff --git a/main.go b/main.go index 23bb60a..6a3a713 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,6 @@ package main import ( - "errors" - "io/ioutil" "net/http" "os" "os/signal" @@ -10,6 +8,7 @@ import ( "syscall" "time" + "github.com/app-sre/aws-resource-exporter/pkg" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/go-kit/kit/log/level" @@ -21,7 +20,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/version" "gopkg.in/alecthomas/kingpin.v2" - "gopkg.in/yaml.v2" ) const ( @@ -33,104 +31,15 @@ const ( var ( listenAddress = kingpin.Flag("web.listen-address", "The address to listen on for HTTP requests.").Default(":9115").String() metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() - - exporterMetrics *ExporterMetrics ) func main() { os.Exit(run()) } -type BaseConfig struct { - Enabled bool `yaml:"enabled"` - Interval *time.Duration `yaml:"interval"` - CacheTTL *time.Duration `yaml:"cache_ttl"` -} - -type RDSConfig struct { - BaseConfig `yaml:"base,inline"` - Regions []string `yaml:"regions"` -} - -type VPCConfig struct { - BaseConfig `yaml:"base,inline"` - Timeout *time.Duration `yaml:"timeout"` - Regions []string `yaml:"regions"` -} - -type Route53Config struct { - BaseConfig `yaml:"base,inline"` - Timeout *time.Duration `yaml:"timeout"` - Region string `yaml:"region"` // Use only a single Region for now, as the current metric is global -} - -type EC2Config struct { - BaseConfig `yaml:"base,inline"` - Timeout *time.Duration `yaml:"timeout"` - Regions []string `yaml:"regions"` -} - -type Config struct { - RdsConfig RDSConfig `yaml:"rds"` - VpcConfig VPCConfig `yaml:"vpc"` - Route53Config Route53Config `yaml:"route53"` - EC2Config EC2Config `yaml:"ec2"` -} - -func durationPtr(duration time.Duration) *time.Duration { - return &duration -} - -func loadExporterConfiguration(logger log.Logger, configFile string) (*Config, error) { - var config Config - file, err := ioutil.ReadFile(configFile) - if err != nil { - level.Error(logger).Log("Could not load configuration file") - return nil, errors.New("Could not load configuration file: " + configFile) - } - yaml.Unmarshal(file, &config) - - if config.RdsConfig.CacheTTL == nil { - config.RdsConfig.CacheTTL = durationPtr(35 * time.Second) - } - if config.VpcConfig.CacheTTL == nil { - config.VpcConfig.CacheTTL = durationPtr(35 * time.Second) - } - if config.Route53Config.CacheTTL == nil { - config.Route53Config.CacheTTL = durationPtr(35 * time.Second) - } - if config.EC2Config.CacheTTL == nil { - config.EC2Config.CacheTTL = durationPtr(35 * time.Second) - } - - if config.RdsConfig.Interval == nil { - config.RdsConfig.Interval = durationPtr(15 * time.Second) - } - if config.VpcConfig.Interval == nil { - config.VpcConfig.Interval = durationPtr(15 * time.Second) - } - if config.Route53Config.Interval == nil { - config.Route53Config.Interval = durationPtr(15 * time.Second) - } - if config.EC2Config.Interval == nil { - config.EC2Config.Interval = durationPtr(15 * time.Second) - } - - if config.VpcConfig.Timeout == nil { - config.VpcConfig.Timeout = durationPtr(10 * time.Second) - } - if config.Route53Config.Timeout == nil { - config.Route53Config.Timeout = durationPtr(10 * time.Second) - } - if config.EC2Config.Timeout == nil { - config.EC2Config.Timeout = durationPtr(10 * time.Second) - } - return &config, nil -} - func setupCollectors(logger log.Logger, configFile string) ([]prometheus.Collector, error) { var collectors []prometheus.Collector - config, err := loadExporterConfiguration(logger, configFile) + config, err := pkg.LoadExporterConfiguration(logger, configFile) if err != nil { return nil, err } @@ -146,7 +55,7 @@ func setupCollectors(logger log.Logger, configFile string) ([]prometheus.Collect sess := session.Must(session.NewSession(config)) vpcSessions = append(vpcSessions, sess) } - vpcExporter := NewVPCExporter(vpcSessions, logger, config.VpcConfig) + vpcExporter := pkg.NewVPCExporter(vpcSessions, logger, config.VpcConfig) collectors = append(collectors, vpcExporter) go vpcExporter.CollectLoop() } @@ -158,7 +67,7 @@ func setupCollectors(logger log.Logger, configFile string) ([]prometheus.Collect sess := session.Must(session.NewSession(config)) rdsSessions = append(rdsSessions, sess) } - rdsExporter := NewRDSExporter(rdsSessions, logger, config.RdsConfig) + rdsExporter := pkg.NewRDSExporter(rdsSessions, logger, config.RdsConfig) collectors = append(collectors, rdsExporter) go rdsExporter.CollectLoop() } @@ -170,7 +79,7 @@ func setupCollectors(logger log.Logger, configFile string) ([]prometheus.Collect sess := session.Must(session.NewSession(config)) ec2Sessions = append(ec2Sessions, sess) } - ec2Exporter := NewEC2Exporter(ec2Sessions, logger, config.EC2Config) + ec2Exporter := pkg.NewEC2Exporter(ec2Sessions, logger, config.EC2Config) collectors = append(collectors, ec2Exporter) go ec2Exporter.CollectLoop() } @@ -178,7 +87,7 @@ func setupCollectors(logger log.Logger, configFile string) ([]prometheus.Collect if config.Route53Config.Enabled { awsConfig := aws.NewConfig().WithRegion(config.Route53Config.Region) sess := session.Must(session.NewSession(awsConfig)) - r53Exporter := NewRoute53Exporter(sess, logger, config.Route53Config) + r53Exporter := pkg.NewRoute53Exporter(sess, logger, config.Route53Config) collectors = append(collectors, r53Exporter) go r53Exporter.CollectLoop() } @@ -197,7 +106,8 @@ func run() int { level.Info(logger).Log("msg", "Starting"+namespace, "version", version.Info()) level.Info(logger).Log("msg", "Build context", version.BuildContext()) - exporterMetrics = NewExporterMetrics() + pkg.AwsExporterMetrics = pkg.NewExporterMetrics() + var configFile string if path := os.Getenv("AWS_RESOURCE_EXPORTER_CONFIG_FILE"); path != "" { configFile = path @@ -209,7 +119,7 @@ func run() int { level.Error(logger).Log("msg", "Could not load configuration file", "err", err) return 1 } - collectors := append(cs, exporterMetrics) + collectors := append(cs, pkg.AwsExporterMetrics) prometheus.MustRegister( collectors..., ) diff --git a/pkg/config.go b/pkg/config.go new file mode 100644 index 0000000..bd736c1 --- /dev/null +++ b/pkg/config.go @@ -0,0 +1,94 @@ +package pkg + +import ( + "errors" + "io/ioutil" + "time" + + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/log/level" + "gopkg.in/yaml.v2" +) + +type BaseConfig struct { + Enabled bool `yaml:"enabled"` + Interval *time.Duration `yaml:"interval"` + CacheTTL *time.Duration `yaml:"cache_ttl"` +} + +type RDSConfig struct { + BaseConfig `yaml:"base,inline"` + Regions []string `yaml:"regions"` +} + +type VPCConfig struct { + BaseConfig `yaml:"base,inline"` + Timeout *time.Duration `yaml:"timeout"` + Regions []string `yaml:"regions"` +} + +type Route53Config struct { + BaseConfig `yaml:"base,inline"` + Timeout *time.Duration `yaml:"timeout"` + Region string `yaml:"region"` // Use only a single Region for now, as the current metric is global +} + +type EC2Config struct { + BaseConfig `yaml:"base,inline"` + Timeout *time.Duration `yaml:"timeout"` + Regions []string `yaml:"regions"` +} + +type Config struct { + RdsConfig RDSConfig `yaml:"rds"` + VpcConfig VPCConfig `yaml:"vpc"` + Route53Config Route53Config `yaml:"route53"` + EC2Config EC2Config `yaml:"ec2"` +} + +func LoadExporterConfiguration(logger log.Logger, configFile string) (*Config, error) { + var config Config + file, err := ioutil.ReadFile(configFile) + if err != nil { + level.Error(logger).Log("Could not load configuration file") + return nil, errors.New("Could not load configuration file: " + configFile) + } + yaml.Unmarshal(file, &config) + + if config.RdsConfig.CacheTTL == nil { + config.RdsConfig.CacheTTL = durationPtr(35 * time.Second) + } + if config.VpcConfig.CacheTTL == nil { + config.VpcConfig.CacheTTL = durationPtr(35 * time.Second) + } + if config.Route53Config.CacheTTL == nil { + config.Route53Config.CacheTTL = durationPtr(35 * time.Second) + } + if config.EC2Config.CacheTTL == nil { + config.EC2Config.CacheTTL = durationPtr(35 * time.Second) + } + + if config.RdsConfig.Interval == nil { + config.RdsConfig.Interval = durationPtr(15 * time.Second) + } + if config.VpcConfig.Interval == nil { + config.VpcConfig.Interval = durationPtr(15 * time.Second) + } + if config.Route53Config.Interval == nil { + config.Route53Config.Interval = durationPtr(15 * time.Second) + } + if config.EC2Config.Interval == nil { + config.EC2Config.Interval = durationPtr(15 * time.Second) + } + + if config.VpcConfig.Timeout == nil { + config.VpcConfig.Timeout = durationPtr(10 * time.Second) + } + if config.Route53Config.Timeout == nil { + config.Route53Config.Timeout = durationPtr(10 * time.Second) + } + if config.EC2Config.Timeout == nil { + config.EC2Config.Timeout = durationPtr(10 * time.Second) + } + return &config, nil +} diff --git a/pkg/constats.go b/pkg/constats.go new file mode 100644 index 0000000..5d385ec --- /dev/null +++ b/pkg/constats.go @@ -0,0 +1,5 @@ +package pkg + +const ( + namespace = "aws_resources_exporter" +) diff --git a/ec2.go b/pkg/ec2.go similarity index 95% rename from ec2.go rename to pkg/ec2.go index 23e4d47..fc740e6 100644 --- a/ec2.go +++ b/pkg/ec2.go @@ -1,11 +1,10 @@ -package main +package pkg import ( "context" "sync" "time" - "github.com/app-sre/aws-resource-exporter/pkg" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" @@ -25,7 +24,7 @@ var TransitGatewaysUsage *prometheus.Desc = prometheus.NewDesc(prometheus.BuildF type EC2Exporter struct { sessions []*session.Session - cache pkg.MetricsCache + cache MetricsCache logger log.Logger timeout time.Duration @@ -37,7 +36,7 @@ func NewEC2Exporter(sessions []*session.Session, logger log.Logger, config EC2Co level.Info(logger).Log("msg", "Initializing EC2 exporter") return &EC2Exporter{ sessions: sessions, - cache: *pkg.NewMetricsCache(*config.CacheTTL), + cache: *NewMetricsCache(*config.CacheTTL), logger: logger, timeout: *config.Timeout, @@ -77,14 +76,14 @@ func (e *EC2Exporter) collectInRegion(sess *session.Session, logger log.Logger, quota, err := getQuotaValueWithContext(serviceQuotaSvc, ec2ServiceCode, transitGatewayPerAccountQuotaCode, ctx) if err != nil { level.Error(logger).Log("msg", "Could not retrieve Transit Gateway quota", "error", err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } gateways, err := getAllTransitGatewaysWithContext(ec2Svc, ctx) if err != nil { level.Error(logger).Log("msg", "Could not retrieve Transit Gateway quota", "error", err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } diff --git a/exporter.go b/pkg/exporter.go similarity index 97% rename from exporter.go rename to pkg/exporter.go index 42b6a15..e09bacc 100644 --- a/exporter.go +++ b/pkg/exporter.go @@ -1,4 +1,4 @@ -package main +package pkg import ( "sync" @@ -7,6 +7,8 @@ import ( "github.com/prometheus/client_golang/prometheus" ) +var AwsExporterMetrics *ExporterMetrics + // ExporterMetrics defines an instance of the exporter metrics type ExporterMetrics struct { sess *session.Session diff --git a/proxy.go b/pkg/proxy.go similarity index 98% rename from proxy.go rename to pkg/proxy.go index 51f0184..d11c677 100644 --- a/proxy.go +++ b/pkg/proxy.go @@ -1,4 +1,4 @@ -package main +package pkg import ( "errors" diff --git a/rds.go b/pkg/rds.go similarity index 98% rename from rds.go rename to pkg/rds.go index 52781bb..7878890 100644 --- a/rds.go +++ b/pkg/rds.go @@ -1,4 +1,4 @@ -package main +package pkg import ( "context" @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/app-sre/aws-resource-exporter/pkg" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/rds" "github.com/go-kit/kit/log" @@ -230,7 +229,7 @@ type RDSExporter struct { logsMetricsTTL int logger log.Logger - cache pkg.MetricsCache + cache MetricsCache interval time.Duration } @@ -336,7 +335,7 @@ func NewRDSExporter(sessions []*session.Session, logger log.Logger, config RDSCo nil, ), logger: logger, - cache: *pkg.NewMetricsCache(*config.CacheTTL), + cache: *NewMetricsCache(*config.CacheTTL), interval: *config.Interval, } } @@ -351,11 +350,11 @@ func (e *RDSExporter) requestRDSLogMetrics(index int, instanceId string) (*RDSLo } for { - exporterMetrics.IncrementRequests() + AwsExporterMetrics.IncrementRequests() result, err := e.svcs[index].DescribeDBLogFiles(input) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeDBLogFiles failed", "region", *e.sessions[index].Config.Region, "instance", &instanceId, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return nil, err } for _, log := range result.DescribeDBLogFiles { @@ -448,11 +447,11 @@ func (e *RDSExporter) CollectLoop() { // If a Marker is found, do pagination until last page var instances []*rds.DBInstance for { - exporterMetrics.IncrementRequests() + AwsExporterMetrics.IncrementRequests() result, err := e.svcs[i].DescribeDBInstances(input) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeDBInstances failed", "region", *e.sessions[i].Config.Region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } instances = append(instances, result.DBInstances...) @@ -544,11 +543,11 @@ func (e *RDSExporter) CollectLoop() { instancesWithPendingMaint := make(map[string]bool) for { - exporterMetrics.IncrementRequests() + AwsExporterMetrics.IncrementRequests() result, err := e.svcs[i].DescribePendingMaintenanceActions(describePendingMaintInput) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribePendingMaintenanceActions failed", "region", *e.sessions[i].Config.Region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } instancesPendMaintActionsData = append(instancesPendMaintActionsData, result.PendingMaintenanceActions...) diff --git a/route53.go b/pkg/route53.go similarity index 96% rename from route53.go rename to pkg/route53.go index 3a03624..eccad15 100644 --- a/route53.go +++ b/pkg/route53.go @@ -1,4 +1,4 @@ -package main +package pkg import ( "context" @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/app-sre/aws-resource-exporter/pkg" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" @@ -35,7 +34,7 @@ type Route53Exporter struct { LastUpdateTime *prometheus.Desc Cancel context.CancelFunc - cache pkg.MetricsCache + cache MetricsCache logger log.Logger interval time.Duration timeout time.Duration @@ -52,7 +51,7 @@ func NewRoute53Exporter(sess *session.Session, logger log.Logger, config Route53 HostedZonesPerAccountQuota: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "route53_hostedzonesperaccount_quota"), "Quota for maximum number of Route53 hosted zones in an account", []string{}, nil), HostedZonesPerAccountUsage: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "route53_hostedzonesperaccount_total"), "Number of Resource records", []string{}, nil), LastUpdateTime: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "route53_last_updated_timestamp_seconds"), "Last time, the route53 metrics were sucessfully updated", []string{}, nil), - cache: *pkg.NewMetricsCache(*config.CacheTTL), + cache: *NewMetricsCache(*config.CacheTTL), logger: logger, interval: *config.Interval, timeout: *config.Timeout, @@ -80,7 +79,7 @@ func (e *Route53Exporter) getRecordsPerHostedZoneMetrics(client *route53.Route53 if err != nil { errChan <- fmt.Errorf("Could not get Limits for hosted zone with ID '%s' and name '%s'. Error was: %s", *hostedZone.Id, *hostedZone.Name, err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } level.Info(e.logger).Log("msg", fmt.Sprintf("Currently at hosted zone: %d / %d", i, len(hostedZones))) @@ -125,19 +124,19 @@ func (e *Route53Exporter) CollectLoop() { level.Info(e.logger).Log("msg", "Got all zones") if err != nil { level.Error(e.logger).Log("msg", "Could not retrieve the list of hosted zones", "error", err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() } err = e.getHostedZonesPerAccountMetrics(serviceQuotaSvc, hostedZones, ctx) if err != nil { level.Error(e.logger).Log("msg", "Could not get limits for hosted zone", "error", err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() } errs := e.getRecordsPerHostedZoneMetrics(route53Svc, hostedZones, ctx) for _, err = range errs { level.Error(e.logger).Log("msg", "Could not get limits for hosted zone", "error", err.Error()) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() } level.Info(e.logger).Log("msg", "Route53 metrics Updated") diff --git a/env.go b/pkg/util.go similarity index 75% rename from env.go rename to pkg/util.go index 3259dfc..ea643af 100644 --- a/env.go +++ b/pkg/util.go @@ -1,8 +1,9 @@ -package main +package pkg import ( "os" "strconv" + "time" ) func GetEnvIntValue(envname string) (*int, error) { @@ -18,3 +19,7 @@ func GetEnvIntValue(envname string) (*int, error) { return nil, nil } } + +func durationPtr(duration time.Duration) *time.Duration { + return &duration +} diff --git a/vpc.go b/pkg/vpc.go similarity index 96% rename from vpc.go rename to pkg/vpc.go index 2bcd4c4..62f8e72 100644 --- a/vpc.go +++ b/pkg/vpc.go @@ -1,11 +1,10 @@ -package main +package pkg import ( "context" "sync" "time" - "github.com/app-sre/aws-resource-exporter/pkg" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" @@ -42,7 +41,7 @@ type VPCExporter struct { logger log.Logger timeout time.Duration - cache pkg.MetricsCache + cache MetricsCache interval time.Duration } @@ -72,7 +71,7 @@ func NewVPCExporter(sess []*session.Session, logger log.Logger, config VPCConfig IPv4BlocksPerVpcUsage: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "vpc_ipv4blockspervpc_usage"), "The usage of ipv4 blocks per vpc", []string{"aws_region", "vpcid"}, nil), logger: logger, timeout: *config.Timeout, - cache: *pkg.NewMetricsCache(*config.CacheTTL), + cache: *NewMetricsCache(*config.CacheTTL), interval: *config.Interval, } } @@ -158,7 +157,7 @@ func (e *VPCExporter) collectVpcsPerRegionQuota(client *servicequotas.ServiceQuo quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_VPCS_PER_REGION) if err != nil { level.Error(e.logger).Log("msg", "Call to VpcsPerRegion ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.VpcsPerRegionQuota, prometheus.GaugeValue, quota, region)) @@ -170,7 +169,7 @@ func (e *VPCExporter) collectVpcsPerRegionUsage(ec2Svc *ec2.EC2, region string) describeVpcsOutput, err := ec2Svc.DescribeVpcsWithContext(ctx, &ec2.DescribeVpcsInput{}) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeVpcs failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } usage := len(describeVpcsOutput.Vpcs) @@ -181,7 +180,7 @@ func (e *VPCExporter) collectSubnetsPerVpcQuota(client *servicequotas.ServiceQuo quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_SUBNETS_PER_VPC) if err != nil { level.Error(e.logger).Log("msg", "Call to SubnetsPerVpc ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.SubnetsPerVpcQuota, prometheus.GaugeValue, quota, region)) @@ -198,7 +197,7 @@ func (e *VPCExporter) collectSubnetsPerVpcUsage(vpc *ec2.Vpc, ec2Svc *ec2.EC2, r }) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeSubnets failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } usage := len(describeSubnetsOutput.Subnets) @@ -209,7 +208,7 @@ func (e *VPCExporter) collectRoutesPerRouteTableQuota(client *servicequotas.Serv quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_ROUTES_PER_ROUTE_TABLE) if err != nil { level.Error(e.logger).Log("msg", "Call to RoutesPerRouteTable ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.RoutesPerRouteTableQuota, prometheus.GaugeValue, quota, region)) @@ -223,7 +222,7 @@ func (e *VPCExporter) collectRoutesPerRouteTableUsage(rtb *ec2.RouteTable, ec2Sv }) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeRouteTables failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } quota := len(descRouteTableOutput.RouteTables) @@ -234,7 +233,7 @@ func (e *VPCExporter) collectInterfaceVpcEndpointsPerVpcQuota(client *servicequo quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_INTERFACE_VPC_ENDPOINTS_PER_VPC) if err != nil { level.Error(e.logger).Log("msg", "Call to InterfaceVpcEndpointsPerVpc ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.InterfaceVpcEndpointsPerVpcQuota, prometheus.GaugeValue, quota, region)) @@ -251,7 +250,7 @@ func (e *VPCExporter) collectInterfaceVpcEndpointsPerVpcUsage(vpc *ec2.Vpc, ec2S }) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeVpcEndpoints failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } quota := len(descVpcEndpoints.VpcEndpoints) @@ -262,7 +261,7 @@ func (e *VPCExporter) collectRoutesTablesPerVpcQuota(client *servicequotas.Servi quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_ROUTE_TABLES_PER_VPC) if err != nil { level.Error(e.logger).Log("msg", "Call to RoutesTablesPerVpc ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.RouteTablesPerVpcQuota, prometheus.GaugeValue, quota, region)) @@ -279,7 +278,7 @@ func (e *VPCExporter) collectRoutesTablesPerVpcUsage(vpc *ec2.Vpc, ec2Svc *ec2.E }) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeRouteTables failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } quota := len(descRouteTables.RouteTables) @@ -290,7 +289,7 @@ func (e *VPCExporter) collectIPv4BlocksPerVpcQuota(client *servicequotas.Service quota, err := e.GetQuotaValue(client, SERVICE_CODE_VPC, QUOTA_IPV4_BLOCKS_PER_VPC) if err != nil { level.Error(e.logger).Log("msg", "Call to IPv4BlocksPerVpc ServiceQuota failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } e.cache.AddMetric(prometheus.MustNewConstMetric(e.IPv4BlocksPerVpcQuota, prometheus.GaugeValue, quota, region)) @@ -304,7 +303,7 @@ func (e *VPCExporter) collectIPv4BlocksPerVpcUsage(vpc *ec2.Vpc, ec2Svc *ec2.EC2 }) if err != nil { level.Error(e.logger).Log("msg", "Call to DescribeVpcs failed", "region", region, "err", err) - exporterMetrics.IncrementErrors() + AwsExporterMetrics.IncrementErrors() return } if len(descVpcs.Vpcs) != 1 {