<commit_before>---
title: prometheus.scrape() function
description: >
  The `prometheus.scrape()` function retrieves Prometheus-formatted metrics
  from a specified URL.
menu:
  flux_0_50:
    name: prometheus.scrape
    parent: Prometheus
weight: 301
related:
  - /v2.0/write-data/scrape-data/scrapable-endpoints/
---

The `prometheus.scrape()` function retrieves [Prometheus-formatted metrics](https://prometheus.io/docs/instrumenting/exposition_formats/)
from a specified URL.
The function groups metrics (including histogram and summary values) into individual tables.

_**Function type:** Input_

{{% warn %}}
The `prometheus.scrape()` function is currently experimental and subject to change at any time.
By using this function, you accept the [risks of experimental functions](/flux/v0.50/stdlib/experimental/#use-experimental-functions-at-your-own-risk).
{{% /warn %}}

```js
import "experimental/prometheus"

prometheus.scrape(
  url: "http://localhost:9999/metrics"
)
```

## Parameters

### url
The URL to scrape Prometheus-formatted metrics from.

_**Data type:** String_

## Examples

### Scrape Prometheus metrics and write them to InfluxDB
```js
import "experimental/prometheus"

prometheus.scrape(url: "https://example-url.com/metrics")
  |> to(
    org: "example-org",
    bucket: "example-bucket"
  )
```
<commit_msg>updated port in prometheus.scrape example, resolves #2556<commit_after>---
title: prometheus.scrape() function
description: >
  The `prometheus.scrape()` function retrieves Prometheus-formatted metrics
  from a specified URL.
menu:
  flux_0_50:
    name: prometheus.scrape
    parent: Prometheus
weight: 301
related:
  - /v2.0/write-data/scrape-data/scrapable-endpoints/
---

The `prometheus.scrape()` function retrieves [Prometheus-formatted metrics](https://prometheus.io/docs/instrumenting/exposition_formats/)
from a specified URL.
The function groups metrics (including histogram and summary values) into individual tables.

_**Function type:** Input_

{{% warn %}}
The `prometheus.scrape()` function is currently experimental and subject to change at any time.
By using this function, you accept the [risks of experimental functions](/flux/v0.50/stdlib/experimental/#use-experimental-functions-at-your-own-risk).
{{% /warn %}}

```js
import "experimental/prometheus"

prometheus.scrape(
  url: "http://localhost:8086/metrics"
)
```

## Parameters

### url
The URL to scrape Prometheus-formatted metrics from.

_**Data type:** String_

## Examples

### Scrape Prometheus metrics and write them to InfluxDB
```js
import "experimental/prometheus"

prometheus.scrape(url: "https://example-url.com/metrics")
  |> to(
    org: "example-org",
    bucket: "example-bucket"
  )
```

{'fraction_non_alphanumeric': 0.13006632277081798, 'fraction_numerical': 0.012527634487840826, 'mean_word_length': 4.703781512605042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4439289', 'n_tokens_mistral': 923, 'n_tokens_neox': 819, 'n_words': 232}