diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/component_diagram.svg b/docs/sources/assets/flow-by-example/diagram-flow-by-example-basic-0.svg similarity index 100% rename from docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/component_diagram.svg rename to docs/sources/assets/flow-by-example/diagram-flow-by-example-basic-0.svg diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/exercise_component_diagram.svg b/docs/sources/assets/flow-by-example/diagram-flow-by-example-exercise-0.svg similarity index 100% rename from docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/exercise_component_diagram.svg rename to docs/sources/assets/flow-by-example/diagram-flow-by-example-exercise-0.svg diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/component_diagram_full.svg b/docs/sources/assets/flow-by-example/diagram-flow-by-example-full-0.svg similarity index 100% rename from docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/component_diagram_full.svg rename to docs/sources/assets/flow-by-example/diagram-flow-by-example-full-0.svg diff --git a/docs/sources/flow/tutorials/flow-by-example/docker-compose.yaml b/docs/sources/flow/tutorials/flow-by-example/docker-compose.yaml new file mode 100644 index 000000000000..4aa14dcc3e63 --- /dev/null +++ b/docs/sources/flow/tutorials/flow-by-example/docker-compose.yaml @@ -0,0 +1,49 @@ +version: '3' +services: + loki: + image: grafana/loki:2.9.0 + ports: + - "3100:3100" + command: -config.file=/etc/loki/local-config.yaml + prometheus: + image: prom/prometheus:v2.47.0 + command: + - --web.enable-remote-write-receiver + - --config.file=/etc/prometheus/prometheus.yml + ports: + - "9090:9090" + grafana: + environment: + - GF_PATHS_PROVISIONING=/etc/grafana/provisioning + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + entrypoint: + - sh + - -euc + - | + mkdir -p /etc/grafana/provisioning/datasources + cat < /etc/grafana/provisioning/datasources/ds.yaml + apiVersion: 1 + datasources: + - name: Loki + type: loki + access: proxy + orgId: 1 + url: http://loki:3100 + basicAuth: false + isDefault: false + version: 1 + editable: false + - name: Prometheus + type: prometheus + orgId: 1 + url: http://prometheus:9090 + basicAuth: false + isDefault: true + version: 1 + editable: false + EOF + /run.sh + image: grafana/grafana:latest + ports: + - "3000:3000" \ No newline at end of file diff --git a/docs/sources/flow/tutorials/flow-by-example/faq.md b/docs/sources/flow/tutorials/flow-by-example/faq.md index 81d7e9d5aab4..7baac5732db0 100644 --- a/docs/sources/flow/tutorials/flow-by-example/faq.md +++ b/docs/sources/flow/tutorials/flow-by-example/faq.md @@ -12,7 +12,7 @@ weight: 300 ## Who is this for? -This repository contains a collection of examples that build on each other to demonstrate how to configure and use the [Grafana Agent](https://grafana.com/docs/agent/latest/) in [Flow mode](https://grafana.com/docs/agent/latest/flow/). It assumes you have a basic understanding of what the Agent is and telemetry collection in general. It also assumes a base level of familiarity with Prometheus and PromQL, Loki and LogQL, and basic Grafana navigation. It assumes no knowledge of Flow or River concepts. +This set of tutorials contains a collection of examples that build on each other to demonstrate how to configure and use the [Grafana Agent](https://grafana.com/docs/agent/latest/) in [Flow mode](https://grafana.com/docs/agent/latest/flow/). It assumes you have a basic understanding of what the Agent is and telemetry collection in general. It also assumes a base level of familiarity with Prometheus and PromQL, Loki and LogQL, and basic Grafana navigation. It assumes no knowledge of Flow or River concepts. ## What is Flow? @@ -26,10 +26,10 @@ To run the examples, you should have a Grafana Agent binary available. You can f ## How should I follow along? -The `docker-compose.yml` file in the root of this repository will start Prometheus, Loki, and Grafana containers to use with the examples. You can start these containers with `docker compose up` and stop them with `docker compose down`. The examples are designed to work with the default configuration of these containers, so you should not need to modify them. +You can click here to download the docker-compose file to run and play with the examples. After running `docker-compose up`, open [http://localhost:3000](http://localhost:3000) in your browser to view the Grafana UI. -The examples in this repository are designed to be followed in order. Examples generally build on each other, and each example contains a README that explains what it does and how it works. The examples are designed to be run locally, so you can follow along and experiment with them yourself. +The tutorials are designed to be followed in order and generally build on each other. Each example explains what it does and how it works. They are designed to be run locally, so you can follow along and experiment with them yourself. -Each example's README will contain a list of Recommended Reading. These are links to documentation that will help you understand the concepts used in the example, and should be read in order. Some information may be included in the README as well, but the Recommended Reading will provide more detail. \ No newline at end of file +Each section of the the tutorials will contain a list of Recommended Reading. These are links to documentation that will help you understand the concepts used in the example, and should be read in order. Some information may be included in the tutorial as well, but the Recommended Reading will provide more detail. diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/_index.md b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/_index.md deleted file mode 100644 index c5f5de9aba3a..000000000000 --- a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/_index.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -aliases: -- /docs/grafana-cloud/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ -- /docs/grafana-cloud/monitor-infrastructure/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ -- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ -- /docs/grafana-cloud/send-data/agent/flow/tutorials/first-components-and-stdlib/ -canonical: https://grafana.com/docs/agent/latest/flow/tutorials/flow-by-example/first-components-and-stdlib/ -description: Learn how to use Grafana Agent Flow -title: First Components and the Standard Library -weight: 300 ---- - -# First Components and the Standard Library - -_This section covers the basics of the River language and the standard library. It then introduces a basic pipeline that collects metrics from the host and sends them to Prometheus._ - -{{< section >}} diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/mem_usage.png b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/mem_usage.png deleted file mode 100644 index 8186ad5fc377..000000000000 Binary files a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/assets/mem_usage.png and /dev/null differ diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/guide.md b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/index.md similarity index 88% rename from docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/guide.md rename to docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/index.md index bb085e1c5e06..d89ad5e5232b 100644 --- a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/guide.md +++ b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/index.md @@ -1,15 +1,19 @@ --- aliases: -- /docs/grafana-cloud/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/guide/ -- /docs/grafana-cloud/monitor-infrastructure/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/guide/ -- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/guide/ -- /docs/grafana-cloud/send-data/agent/flow/tutorials/first-components-and-stdlib/guide/ -canonical: https://grafana.com/docs/agent/latest/flow/tutorials/flow-by-example/first-components-and-stdlib/guide/ +- /docs/grafana-cloud/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ +- /docs/grafana-cloud/monitor-infrastructure/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ +- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/ +- /docs/grafana-cloud/send-data/agent/flow/tutorials/first-components-and-stdlib/ +canonical: https://grafana.com/docs/agent/latest/flow/tutorials/flow-by-example/first-components-and-stdlib/ description: Learn about the basics of River and the Flow configuration language -title: Guide +title: First Components and Introducing the Standard Library weight: 300 --- +# First Components and the Standard Library + +_This section covers the basics of the River language and the standard library. It then introduces a basic pipeline that collects metrics from the host and sends them to Prometheus._ + ## River basics [Flow Configuration Language]: {{< relref "../../../config-language" >}} @@ -92,10 +96,9 @@ This pipeline has two components: `local.file` and `prometheus.remote_write`. Th The `prometheus.remote_write` component is configured with an `endpoint` block, which contains the `url` attribute and a `basic_auth` block. The `url` attribute is set to the URL of the Prometheus remote write endpoint. The `basic_auth` block contains the `username` and `password` attributes, which are set to the string `"admin"` and the `content` export of the `local.file` component, respectively. Note that the `content` export is referenced by using the syntax `local.file.example.content`, where `local.file.example` is the fully qualified name of the component (the component's type + it's label) and `content` is the name of the export.

-Flow of example pipeline +Flow of example pipeline with local.file and prometheus.remote_write components

- **Pro tip**: _The `local.file` component's label is set to `"example"`, so the fully qualified name of the component is `local.file.example`. The `prometheus.remote_write` component's label is set to `"local_prom"`, so the fully qualified name of the component is `prometheus.remote_write.local_prom`._ This example pipeline still doesn't do anything, so let's add some more components to it. @@ -144,12 +147,16 @@ Run the agent with: And navigate to [http://localhost:3000/explore](http://localhost:3000/explore) in your browser. After ~15-20 seconds you should be able to see the metrics from the `prometheus.exporter.unix` component! Try querying for `node_memory_Active_bytes` to see the active memory of your host. +

+Screenshot of node_memory_Active_bytes query in Grafana +

+ ## Visualizing the Relationship Between Components Let's look at an example pipeline:

-Flow of example pipeline +Flow of example pipeline with a prometheus.scrape, prometheus.exporter.unix, and prometheus.remote_write components

The above configuration defines three components: @@ -166,7 +173,6 @@ One rule is that components cannot form a cycle. This means that a component can [prometheus.exporter.redis]: {{< relref "../../../reference/components/prometheus.exporter.redis.md" >}} [concat]: {{< relref "../../../reference/stdlib/concat" >}} -[solution]: {{< relref "./solution.md" >}} **Recommended Reading** @@ -183,12 +189,12 @@ Try modifying the above pipeline to also scrape metrics from the Redis exporter. To give a visual hint, you want to create a pipeline that looks like this:

-Flow of example pipeline +Flow of exercise pipeline, with a scrape, unix_exporter, redis_exporter, and remote_write component

_Hint: You may find the [concat][] standard library function useful._ -If you get stuck, you can always look at the [solution][]. +If you get stuck, you can always click here to download the solution. You can run the agent with the new config file by running: diff --git a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.md b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.river similarity index 63% rename from docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.md rename to docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.river index d4d95d226764..30d00ccc5119 100644 --- a/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.md +++ b/docs/sources/flow/tutorials/flow-by-example/first-components-and-stdlib/solution.river @@ -1,22 +1,3 @@ ---- -aliases: -- /docs/grafana-cloud/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/full-config/ -- /docs/grafana-cloud/monitor-infrastructure/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/full-config/ -- /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/tutorials/flow-by-example/first-components-and-stdlib/full-config/ -- /docs/grafana-cloud/send-data/agent/flow/tutorials/full-config/ -canonical: https://grafana.com/docs/agent/latest/flow/tutorials/flow-by-example/first-components-and-stdlib/full-config/ -description: Solution to the First Components and Standard Library Exercise -title: Solution -weight: 300 ---- - -# Solution - -[this section's example]: {{< relref "./guide/#exercise-for-the-reader" >}} - -_This is the solution for [this section's example][]._ - -```river // Configure your first components, learn about the standard library, and learn how to run the Agent! // prometheus.exporter.redis collects information about Redis and exposes @@ -49,4 +30,3 @@ prometheus.remote_write "local_prom" { url = "http://localhost:9090/api/v1/write" } } -``` \ No newline at end of file