Search in sources :

Example 1 with ScrapeConfigProvider

use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.

the class TaskThreadPoolTest method constructor.

@Test
public void constructor() {
    ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
    ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
    expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
    expect(scrapeConfig.getNumTaskThreads()).andReturn(2);
    replayAll();
    new TaskThreadPool(scrapeConfigProvider);
    verifyAll();
}
Also used : ScrapeConfigProvider(ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider) ScrapeConfig(ai.asserts.aws.cloudwatch.config.ScrapeConfig) Test(org.junit.jupiter.api.Test)

Example 2 with ScrapeConfigProvider

use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.

the class LambdaCapacityExporterTest method setup.

@BeforeEach
public void setup() {
    ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
    ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
    namespaceConfig = mock(NamespaceConfig.class);
    awsClientProvider = mock(AWSClientProvider.class);
    lambdaClient = mock(LambdaClient.class);
    metricNameUtil = mock(MetricNameUtil.class);
    metricCollector = mock(BasicMetricCollector.class);
    functionScraper = mock(LambdaFunctionScraper.class);
    resourceTagHelper = mock(ResourceTagHelper.class);
    resource = mock(Resource.class);
    sampleBuilder = mock(MetricSampleBuilder.class);
    sample = mock(Sample.class);
    familySamples = mock(Collector.MetricFamilySamples.class);
    resetAll();
    testClass = new LambdaCapacityExporter(scrapeConfigProvider, awsClientProvider, metricNameUtil, sampleBuilder, functionScraper, resourceTagHelper, new RateLimiter(metricCollector));
    expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
    expect(scrapeConfig.getLambdaConfig()).andReturn(Optional.of(namespaceConfig));
    expect(metricNameUtil.getLambdaMetric("available_concurrency")).andReturn("available");
    expect(metricNameUtil.getLambdaMetric("requested_concurrency")).andReturn("requested");
    expect(metricNameUtil.getLambdaMetric("allocated_concurrency")).andReturn("allocated");
    expect(metricNameUtil.getLambdaMetric("timeout_seconds")).andReturn("timeout");
    expect(metricNameUtil.getLambdaMetric("memory_limit_mb")).andReturn("memory_limit");
    expect(metricNameUtil.getLambdaMetric("account_limit")).andReturn("limit");
    expect(metricNameUtil.getLambdaMetric("reserved_concurrency")).andReturn("reserved");
    fn1 = LambdaFunction.builder().account("account1").region("region1").arn("arn1").name("fn1").memoryMB(128).timeoutSeconds(120).build();
    fn1Labels = ImmutableMap.of("region", "region1", "d_function_name", "fn1", "job", "fn1", "cw_namespace", "AWS/Lambda", SCRAPE_ACCOUNT_ID_LABEL, "account1");
    fn1VersionLabels = new HashMap<>(ImmutableMap.of("region", "region1", "d_function_name", "fn1", "d_executed_version", "1", "job", "fn1", "cw_namespace", "AWS/Lambda"));
    fn1VersionLabels.put(SCRAPE_ACCOUNT_ID_LABEL, "account1");
    fn2 = LambdaFunction.builder().account("account2").region("region2").arn("arn2").name("fn2").memoryMB(128).timeoutSeconds(60).build();
    fn2Labels = ImmutableMap.of("region", "region2", "d_function_name", "fn2", "job", "fn2", "cw_namespace", "AWS/Lambda", SCRAPE_ACCOUNT_ID_LABEL, "account2");
    fn2ResourceLabels = new HashMap<>(ImmutableMap.of("region", "region2", "d_function_name", "fn2", "d_resource", "green", "job", "fn2", "cw_namespace", "AWS/Lambda"));
    fn2ResourceLabels.put(SCRAPE_ACCOUNT_ID_LABEL, "account2");
}
Also used : NamespaceConfig(ai.asserts.aws.cloudwatch.config.NamespaceConfig) Sample(io.prometheus.client.Collector.MetricFamilySamples.Sample) Resource(ai.asserts.aws.resource.Resource) AWSClientProvider(ai.asserts.aws.AWSClientProvider) LambdaFunctionScraper(ai.asserts.aws.lambda.LambdaFunctionScraper) RateLimiter(ai.asserts.aws.RateLimiter) ScrapeConfigProvider(ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider) LambdaClient(software.amazon.awssdk.services.lambda.LambdaClient) MetricNameUtil(ai.asserts.aws.MetricNameUtil) ResourceTagHelper(ai.asserts.aws.resource.ResourceTagHelper) ScrapeConfig(ai.asserts.aws.cloudwatch.config.ScrapeConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ScrapeConfigProvider

use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.

the class LambdaInvokeConfigExporterTest method setup.

@BeforeEach
public void setup() {
    fnScraper = mock(LambdaFunctionScraper.class);
    awsClientProvider = mock(AWSClientProvider.class);
    lambdaClient = mock(LambdaClient.class);
    metricNameUtil = mock(MetricNameUtil.class);
    ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
    ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
    NamespaceConfig namespaceConfig = mock(NamespaceConfig.class);
    resourceMapper = mock(ResourceMapper.class);
    resource = mock(Resource.class);
    metricSampleBuilder = mock(MetricSampleBuilder.class);
    sample = mock(Collector.MetricFamilySamples.Sample.class);
    metricCollector = mock(BasicMetricCollector.class);
    testClass = new LambdaInvokeConfigExporter(fnScraper, awsClientProvider, metricNameUtil, scrapeConfigProvider, resourceMapper, metricSampleBuilder, new RateLimiter(metricCollector));
    expect(scrapeConfig.getLambdaConfig()).andReturn(Optional.of(namespaceConfig));
    expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
    expect(metricNameUtil.getMetricPrefix(CWNamespace.lambda.getNamespace())).andReturn("prefix");
}
Also used : NamespaceConfig(ai.asserts.aws.cloudwatch.config.NamespaceConfig) Resource(ai.asserts.aws.resource.Resource) AWSClientProvider(ai.asserts.aws.AWSClientProvider) LambdaFunctionScraper(ai.asserts.aws.lambda.LambdaFunctionScraper) RateLimiter(ai.asserts.aws.RateLimiter) ScrapeConfigProvider(ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider) LambdaClient(software.amazon.awssdk.services.lambda.LambdaClient) ResourceMapper(ai.asserts.aws.resource.ResourceMapper) Collector(io.prometheus.client.Collector) MetricNameUtil(ai.asserts.aws.MetricNameUtil) ScrapeConfig(ai.asserts.aws.cloudwatch.config.ScrapeConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ScrapeConfigProvider

use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.

the class EC2ToEBSVolumeExporterTest method setup.

@BeforeEach
public void setup() {
    AccountIDProvider accountIDProvider = mock(AccountIDProvider.class);
    AWSClientProvider awsClientProvider = mock(AWSClientProvider.class);
    ec2Client = mock(Ec2Client.class);
    ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
    ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
    metricCollector = mock(BasicMetricCollector.class);
    testClass = new EC2ToEBSVolumeExporter(accountIDProvider, scrapeConfigProvider, awsClientProvider, new RateLimiter(metricCollector));
    expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
    expect(scrapeConfig.getRegions()).andReturn(ImmutableSet.of("region"));
    expect(awsClientProvider.getEc2Client("region")).andReturn(ec2Client);
    expect(accountIDProvider.getAccountId()).andReturn("account").anyTimes();
}
Also used : AWSClientProvider(ai.asserts.aws.AWSClientProvider) Ec2Client(software.amazon.awssdk.services.ec2.Ec2Client) RateLimiter(ai.asserts.aws.RateLimiter) ScrapeConfigProvider(ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider) ScrapeConfig(ai.asserts.aws.cloudwatch.config.ScrapeConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ScrapeConfigProvider

use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.

the class LBToLambdaRoutingBuilderTest method setup.

@BeforeEach
public void setup() {
    AccountIDProvider accountIDProvider = mock(AccountIDProvider.class);
    ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
    ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
    AWSClientProvider awsClientProvider = mock(AWSClientProvider.class);
    TargetGroupLBMapProvider targetGroupLBMapProvider = mock(TargetGroupLBMapProvider.class);
    metricCollector = mock(BasicMetricCollector.class);
    elbV2Client = mock(ElasticLoadBalancingV2Client.class);
    resourceMapper = mock(ResourceMapper.class);
    targetResource = mock(Resource.class);
    lbRsource = mock(Resource.class);
    lambdaResource = mock(Resource.class);
    testClass = new LBToLambdaRoutingBuilder(accountIDProvider, scrapeConfigProvider, awsClientProvider, new RateLimiter(metricCollector), resourceMapper, targetGroupLBMapProvider);
    expect(accountIDProvider.getAccountId()).andReturn("account").anyTimes();
    expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig).anyTimes();
    expect(scrapeConfig.getRegions()).andReturn(ImmutableSet.of("region")).anyTimes();
    expect(awsClientProvider.getELBV2Client("region")).andReturn(elbV2Client).anyTimes();
    expect(targetGroupLBMapProvider.getTgToLB()).andReturn(ImmutableMap.of(targetResource, lbRsource));
}
Also used : ResourceMapper(ai.asserts.aws.resource.ResourceMapper) Resource(ai.asserts.aws.resource.Resource) AWSClientProvider(ai.asserts.aws.AWSClientProvider) ElasticLoadBalancingV2Client(software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client) RateLimiter(ai.asserts.aws.RateLimiter) ScrapeConfigProvider(ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider) ScrapeConfig(ai.asserts.aws.cloudwatch.config.ScrapeConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ScrapeConfigProvider (ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider)13 AWSClientProvider (ai.asserts.aws.AWSClientProvider)12 RateLimiter (ai.asserts.aws.RateLimiter)11 BeforeEach (org.junit.jupiter.api.BeforeEach)11 ScrapeConfig (ai.asserts.aws.cloudwatch.config.ScrapeConfig)10 Resource (ai.asserts.aws.resource.Resource)7 ResourceMapper (ai.asserts.aws.resource.ResourceMapper)6 NamespaceConfig (ai.asserts.aws.cloudwatch.config.NamespaceConfig)5 MetricNameUtil (ai.asserts.aws.MetricNameUtil)4 LambdaClient (software.amazon.awssdk.services.lambda.LambdaClient)4 ResourceTagHelper (ai.asserts.aws.resource.ResourceTagHelper)3 ObjectMapperFactory (ai.asserts.aws.ObjectMapperFactory)2 BasicMetricCollector (ai.asserts.aws.exporter.BasicMetricCollector)2 LambdaFunctionScraper (ai.asserts.aws.lambda.LambdaFunctionScraper)2 Sample (io.prometheus.client.Collector.MetricFamilySamples.Sample)2 Test (org.junit.jupiter.api.Test)2 ElasticLoadBalancingV2Client (software.amazon.awssdk.services.elasticloadbalancingv2.ElasticLoadBalancingV2Client)2 AccountIDProvider (ai.asserts.aws.exporter.AccountIDProvider)1 StaticConfig (ai.asserts.aws.exporter.ECSServiceDiscoveryExporter.StaticConfig)1 LabelBuilder (ai.asserts.aws.exporter.LabelBuilder)1