createScraper method
The CreateScraper operation creates a scraper to collect
metrics. A scraper pulls metrics from Prometheus-compatible sources and
sends them to your Amazon Managed Service for Prometheus workspace. You
can configure scrapers to collect metrics from Amazon EKS clusters, Amazon
MSK clusters, or from VPC-based sources that support DNS-based service
discovery. Scrapers are flexible, and can be configured to control what
metrics are collected, the frequency of collection, what transformations
are applied to the metrics, and more.
An IAM role will be created for you that Amazon Managed Service for Prometheus uses to access the metrics in your source. You must configure this role with a policy that allows it to scrape metrics from your source. For Amazon EKS sources, see Configuring your Amazon EKS cluster in the Amazon Managed Service for Prometheus User Guide.
The scrapeConfiguration parameter contains the base-64
encoded YAML configuration for the scraper.
When creating a scraper, the service creates a Network
Interface in each Availability Zone that are passed into
CreateScraper through subnets. These network interfaces are
used to connect to your source within the VPC for scraping metrics.
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter destination :
The Amazon Managed Service for Prometheus workspace to send metrics to.
Parameter scrapeConfiguration :
The configuration file to use in the new scraper. For more information,
see Scraper
configuration in the Amazon Managed Service for Prometheus User
Guide.
Parameter source :
The Amazon EKS or Amazon Web Services cluster from which the scraper will
collect metrics.
Parameter alias :
(optional) An alias to associate with the scraper. This is for your use,
and does not need to be unique.
Parameter clientToken :
(Optional) A unique, case-sensitive identifier that you can provide to
ensure the idempotency of the request.
Parameter roleConfiguration :
Use this structure to enable cross-account access, so that you can use a
target account to access Prometheus metrics from source accounts.
Parameter tags :
(Optional) The list of tag keys and values to associate with the scraper.
Implementation
Future<CreateScraperResponse> createScraper({
required Destination destination,
required ScrapeConfiguration scrapeConfiguration,
required Source source,
String? alias,
String? clientToken,
RoleConfiguration? roleConfiguration,
Map<String, String>? tags,
}) async {
final $payload = <String, dynamic>{
'destination': destination,
'scrapeConfiguration': scrapeConfiguration,
'source': source,
if (alias != null) 'alias': alias,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (roleConfiguration != null) 'roleConfiguration': roleConfiguration,
if (tags != null) 'tags': tags,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/scrapers',
exceptionFnMap: _exceptionFns,
);
return CreateScraperResponse.fromJson(response);
}