scrapers
Creates, updates, deletes, gets or lists a scrapers resource.
Overview
| Name | scrapers |
| Type | Resource |
| Id | aws.amp.scrapers |
Fields
The following fields are returned by SELECT queries:
- describe_scraper
- list_scrapers
| Name | Datatype | Description |
|---|---|---|
alias | string | An optional user-assigned scraper alias. (pattern: <code>[0-9A-Za-z][-.0-9A-Z_a-z]*</code>) |
arn | string | The Amazon Resource Name (ARN) of the scraper. For example, arn:aws:aps:<region>:123456798012:scraper/s-example1-1234-abcd-5678-ef9012abcd34. |
created_at | string (date-time) | The date and time that the scraper was created. |
destination | object | Where to send the metrics from a scraper. |
exporters | array | A list of exporter configurations for a scraper. You can configure at most one Amazon OpenSearch Service domain. |
last_modified_at | string (date-time) | The date and time that the scraper was last modified. |
role_arn | string | The Amazon Resource Name (ARN) of the IAM role that provides permissions for the scraper to discover and collect metrics on your behalf. For example, arn:aws:iam::123456789012:role/service-role/AmazonGrafanaServiceRole-12example. (pattern: <code>arn:aws[-a-z]*:iam::[0-9]{12}:role/.+</code>) |
role_configuration | object | Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts. |
scrape_configuration | object | A scrape configuration for a scraper, base 64 encoded. For more information, see Scraper configuration in the Amazon Managed Service for Prometheus User Guide. |
scraper_id | string | A scraper ID. (pattern: <code>[0-9A-Za-z][-.0-9A-Z_a-z]*</code>) |
source | object | The source of collected metrics for a scraper. |
status | object | A structure that contains the current status of the scraper. |
status_reason | string | If there is a failure, the reason for the failure. |
tags | object | (Optional) The list of tag keys and values associated with the scraper. |
| Name | Datatype | Description |
|---|---|---|
alias | string | An optional user-assigned scraper alias. (pattern: <code>[0-9A-Za-z][-.0-9A-Z_a-z]*</code>) |
arn | string | The Amazon Resource Name (ARN) of the scraper. |
created_at | string (date-time) | The date and time that the scraper was created. |
destination | object | Where to send the metrics from a scraper. |
exporters | array | A list of exporter configurations for a scraper. You can configure at most one Amazon OpenSearch Service domain. |
last_modified_at | string (date-time) | The date and time that the scraper was last modified. |
role_arn | string | The Amazon Resource Name (ARN) of the IAM role that provides permissions for the scraper to discover and collect metrics on your behalf. (pattern: <code>arn:aws[-a-z]*:iam::[0-9]{12}:role/.+</code>) |
role_configuration | object | Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts. |
scraper_id | string | The ID of the scraper. (pattern: <code>[0-9A-Za-z][-.0-9A-Z_a-z]*</code>) |
source | object | The source of collected metrics for a scraper. |
status | object | A structure that contains the current status of the scraper. |
status_reason | string | If there is a failure, the reason for the failure. |
tags | object | (Optional) The list of tag keys and values associated with the scraper. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_scraper | select | scraper_id, region | The DescribeScraper operation displays information about an existing scraper. | |
list_scrapers | select | region | filters, nextToken, maxResults | The ListScrapers operation lists all of the scrapers in your account. This includes scrapers being created or deleted. You can optionally filter the returned list. |
create_scraper | insert | region, scrapeConfiguration, source, destination | 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. | |
update_scraper | update | scraper_id, region | Updates an existing scraper. You can't use this function to update the source from which the scraper is collecting metrics. To change the source, delete the scraper and create a new one. | |
delete_scraper | delete | scraper_id, region | clientToken | The DeleteScraper operation deletes one scraper, and stops any metrics collection that the scraper performs. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
scraper_id | string | The ID of the scraper to delete. |
clientToken | string | (Optional) A unique, case-sensitive identifier that you can provide to ensure the idempotency of the request. |
filters | object | (Optional) A list of key-value pairs to filter the list of scrapers returned. Keys include status, sourceArn, destinationArn, and alias. Filters on the same key are OR'd together, and filters on different keys are AND'd together. For example, status=ACTIVE&status=CREATING&alias=Test, will return all scrapers that have the alias Test, and are either in status ACTIVE or CREATING. To find all active scrapers that are sending metrics to a specific Amazon Managed Service for Prometheus workspace, you would use the ARN of the workspace in a query: status=ACTIVE&destinationArn=arn:aws:aps:us-east-1:123456789012:workspace/ws-example1-1234-abcd-56ef-123456789012 If this is included, it filters the results to only the scrapers that match the filter. |
maxResults | integer | Optional) The maximum number of scrapers to return in one ListScrapers operation. The range is 1-1000. If you omit this parameter, the default of 100 is used. |
nextToken | string | (Optional) The token for the next set of items to return. (You received this token from a previous call.) |
SELECT examples
- describe_scraper
- list_scrapers
The DescribeScraper operation displays information about an existing scraper.
SELECT
alias,
arn,
created_at,
destination,
exporters,
last_modified_at,
role_arn,
role_configuration,
scrape_configuration,
scraper_id,
source,
status,
status_reason,
tags
FROM aws.amp.scrapers
WHERE scraper_id = '{{ scraper_id }}' -- required
AND region = '{{ region }}' -- required
;
The ListScrapers operation lists all of the scrapers in your account. This includes scrapers being created or deleted. You can optionally filter the returned list.
SELECT
alias,
arn,
created_at,
destination,
exporters,
last_modified_at,
role_arn,
role_configuration,
scraper_id,
source,
status,
status_reason,
tags
FROM aws.amp.scrapers
WHERE region = '{{ region }}' -- required
AND filters = '{{ filters }}'
AND nextToken = '{{ nextToken }}'
AND maxResults = '{{ maxResults }}'
;
INSERT examples
- create_scraper
- Manifest
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.
INSERT INTO aws.amp.scrapers (
alias,
scrapeConfiguration,
source,
destination,
roleConfiguration,
clientToken,
tags,
exporters,
region
)
SELECT
'{{ alias }}',
'{{ scrapeConfiguration }}' /* required */,
'{{ source }}' /* required */,
'{{ destination }}' /* required */,
'{{ roleConfiguration }}',
'{{ clientToken }}',
'{{ tags }}',
'{{ exporters }}',
'{{ region }}'
RETURNING
arn,
scraper_id,
status,
tags
;
# Description fields are for documentation purposes
- name: scrapers
props:
- name: region
value: "{{ region }}"
description: Required parameter for the scrapers resource.
- name: alias
value: "{{ alias }}"
description: |
An optional user-assigned scraper alias.
- name: scrapeConfiguration
description: |
A scrape configuration for a scraper, base 64 encoded. For more information, see Scraper configuration in the Amazon Managed Service for Prometheus User Guide.
value:
configurationBlob: "{{ configurationBlob }}"
- name: source
description: |
The source of collected metrics for a scraper.
value:
eksConfiguration:
clusterArn: "{{ clusterArn }}"
securityGroupIds:
- "{{ securityGroupIds }}"
subnetIds:
- "{{ subnetIds }}"
vpcConfiguration:
securityGroupIds:
- "{{ securityGroupIds }}"
subnetIds:
- "{{ subnetIds }}"
- name: destination
description: |
Where to send the metrics from a scraper.
value:
ampConfiguration:
workspaceArn: "{{ workspaceArn }}"
cloudWatchConfiguration:
datasetArn: "{{ datasetArn }}"
- name: roleConfiguration
description: |
Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts.
value:
sourceRoleArn: "{{ sourceRoleArn }}"
targetRoleArn: "{{ targetRoleArn }}"
- name: clientToken
value: "{{ clientToken }}"
description: |
An identifier used to ensure the idempotency of a write request.
- name: tags
value: "{{ tags }}"
description: |
A tag associated with a resource.
- name: exporters
description: |
A list of exporter configurations for a scraper. You can configure at most one Amazon OpenSearch Service domain.
value:
- openSearchConfiguration:
domainArn: "{{ domainArn }}"
UPDATE examples
- update_scraper
Updates an existing scraper. You can't use this function to update the source from which the scraper is collecting metrics. To change the source, delete the scraper and create a new one.
UPDATE aws.amp.scrapers
SET
alias = '{{ alias }}',
scrapeConfiguration = '{{ scrapeConfiguration }}',
destination = '{{ destination }}',
roleConfiguration = '{{ roleConfiguration }}',
clientToken = '{{ clientToken }}',
exporters = '{{ exporters }}'
WHERE
scraper_id = '{{ scraper_id }}' --required
AND region = '{{ region }}' --required
RETURNING
arn,
scraper_id,
status,
tags;
DELETE examples
- delete_scraper
The DeleteScraper operation deletes one scraper, and stops any metrics collection that the scraper performs.
DELETE FROM aws.amp.scrapers
WHERE scraper_id = '{{ scraper_id }}' --required
AND region = '{{ region }}' --required
AND clientToken = '{{ clientToken }}'
;