create_scraper
async
¶
create_scraper(
scrape_configuration: ScrapeConfiguration,
source: Source,
destination: Destination,
*,
config_overrides: Optional[AsyncampClientConfig] = None,
alias: Optional[ScraperAlias] = None,
role_configuration: Optional[RoleConfiguration] = None,
client_token: Optional[IdempotencyToken] = None,
tags: Optional[TagMap] = None,
exporters: Optional[ExporterList] = None,
) -> CreateScraperResponse
Creates a scraper to collect metrics from Prometheus-compatible sources. The scraper sends the collected metrics to Amazon Managed Service for Prometheus workspaces or CloudWatch datasets. 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. You can configure a scraper to control which metrics to collect, the frequency of collection, which transformations to apply 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.
For more information about collectors, including what metrics are collected, and how to configure the scraper, see Using an Amazon Web Services managed collector in the Amazon Managed Service for Prometheus User Guide.
Parameters:
-
alias(Optional[ScraperAlias], default:None) –(optional) An alias to associate with the scraper. This is for your use, and does not need to be unique.
-
scrape_configuration(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.
-
source(Source) –The Amazon EKS or Amazon Web Services cluster from which the scraper will collect metrics.
-
destination(Destination) –The destination where the scraper sends the collected metrics. Valid destinations are Amazon Managed Service for Prometheus workspaces and CloudWatch datasets.
-
role_configuration(Optional[RoleConfiguration], default:None) –Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts.
-
client_token(Optional[IdempotencyToken], default:None) –(Optional) A unique, case-sensitive identifier that you can provide to ensure the idempotency of the request.
-
tags(Optional[TagMap], default:None) –(Optional) The list of tag keys and values to associate with the scraper.
-
exporters(Optional[ExporterList], default:None) –The exporter configurations for the scraper. You can configure at most one Amazon OpenSearch Service domain. If you don't specify a value, the scraper is created without an exporter configuration.
Raises:
-
AccessDeniedException–You do not have sufficient access to perform this action.
-
ConflictException–The request would cause an inconsistent state.
-
InternalServerException–An unexpected error occurred during the processing of the request.
-
ResourceNotFoundException–The request references a resources that doesn't exist.
-
ServiceQuotaExceededException–Completing the request would cause a service quota to be exceeded.
-
ThrottlingException–The request was denied due to request throttling.
-
ValidationException–The input fails to satisfy the constraints specified by an Amazon Web Services service.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
CreateScraper with optional alias input, optional clientToken input, and one set of tags
>>> await client.create_scraper(alias='alias', scrape_configuration={'configurationBlob': 'blob'}, source={'eksConfiguration': {'clusterArn': 'arn:aws:eks:us-west-2:123456789012:cluster/example', 'securityGroupIds': ['sg-abc123'], 'subnetIds': ['subnet-abc123']}}, destination={'ampConfiguration': {'workspaceArn': 'arn:aws:aps:us-west-2:123456789012:workspace/ws-ogh2u499-ce12-hg89-v6c7-123412341234'}}, client_token='token', tags={'exampleTag': 'exampleValue'})
CreateScraper with generic VPC config with mandatory securityGroupIds and subnetIds
>>> await client.create_scraper(alias='alias', scrape_configuration={'configurationBlob': 'blob'}, source={'vpcConfiguration': {'securityGroupIds': ['sg-abc123'], 'subnetIds': ['subnet-abc123']}}, destination={'ampConfiguration': {'workspaceArn': 'arn:aws:aps:us-west-2:123456789012:workspace/ws-ogh2u499-ce12-hg89-v6c7-123412341234'}}, client_token='token', tags={'exampleTag': 'exampleValue'})
Source code in docs_src/capo_amp/_services/async_amp.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |