Skip to content

Commit

Permalink
Update strucutre to leaf bundles, move some assets to shared director…
Browse files Browse the repository at this point in the history
…y, add docker-compose and update FAQ
  • Loading branch information
spartan0x117 committed Nov 30, 2023
1 parent 47512a8 commit 2db0314
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 53 deletions.
49 changes: 49 additions & 0 deletions docs/sources/flow/tutorials/flow-by-example/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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 <<EOF > /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"
8 changes: 4 additions & 4 deletions docs/sources/flow/tutorials/flow-by-example/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -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 <a href="../docker-compose.yaml" download="docker-compose.yaml">click here to download the docker-compose</a> 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.
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.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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" >}}
Expand Down Expand Up @@ -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.

<p align="center">
<img src="../assets/component_diagram.svg" alt="Flow of example pipeline" width="200" />
<img src="../../../../assets/flow-by-example/diagram-flow-by-example-basic-0.svg" alt="Flow of example pipeline with local.file and prometheus.remote_write components" width="200" />
</p>


**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.
Expand Down Expand Up @@ -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.

<p align="center">
<img src="/media/docs/agent/screenshot-flow-by-example-memory-usage.png" alt="Screenshot of node_memory_Active_bytes query in Grafana" />
</p>

## Visualizing the Relationship Between Components

Let's look at an example pipeline:

<p align="center">
<img src="../assets/component_diagram_full.svg" alt="Flow of example pipeline" width="400" />
<img src="../../../../assets/flow-by-example/diagram-flow-by-example-full-0.svg" alt="Flow of example pipeline with a prometheus.scrape, prometheus.exporter.unix, and prometheus.remote_write components" width="400" />
</p>

The above configuration defines three components:
Expand All @@ -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**

Expand All @@ -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:

<p align="center">
<img src="../assets/exercise_component_diagram.svg" alt="Flow of example pipeline" width="600" />
<img src="../../../../assets/flow-by-example/diagram-flow-by-example-exercise-0.svg" alt="Flow of exercise pipeline, with a scrape, unix_exporter, redis_exporter, and remote_write component" width="600" />
</p>

_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 <a href="./solution.river" download="solution.river">click here to download the solution</a>.

You can run the agent with the new config file by running:

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -49,4 +30,3 @@ prometheus.remote_write "local_prom" {
url = "http://localhost:9090/api/v1/write"
}
}
```

0 comments on commit 2db0314

Please sign in to comment.