---
title: "Expressions | Grafana Cloud documentation"
description: "Learn about expressions and functions in Alloy"
---

# Expressions

You learned about components and how they work together in pipelines in the previous sections. Now you’ll learn about *expressions*. These are the mechanism that makes your configurations dynamic by computing values and connecting components together.

Expressions are the key to Alloy’s flexibility. They let you reference data from other components, transform values using functions, and create dynamic configurations that respond to changing conditions.

## How expressions work

Expressions compute values that you assign to component arguments. The component controller evaluates expressions when components start and whenever their dependencies change.

Basic expressions are literal values like `"Hello, world!"` or `true`. More powerful expressions can reference component exports, call functions, or perform calculations.

All component arguments have an underlying [type](/docs/grafana-cloud/send-data/alloy/get-started/expressions/types_and_values). Alloy checks the expression type during evaluation to ensure compatibility before assigning the result to an attribute. This type checking prevents configuration errors and ensures your pipelines work correctly.

## Expression types

The four main types of expressions you’ll use are:

1. **Literal values**: Constants like `"debug"`, `8080`, or `true`.
2. **Component references**: Values from other components like `local.file.config.content`.
3. **Function calls**: Built-in functions like `sys.env("HOME")` or `encoding.from_json(local.file.data.content)`.
4. **Arithmetic operations**: Mathematical calculations like `1 + 2` or `port_base + offset`.

You can combine these types to create complex expressions that transform data and connect components in sophisticated ways.

## Next steps

Now that you understand how expressions work, learn to write different types of expressions:

- [Component exports](/docs/grafana-cloud/send-data/alloy/get-started/expressions/referencing_exports) - Reference data from other components to connect your pipeline
- [Types and values](/docs/grafana-cloud/send-data/alloy/get-started/expressions/types_and_values) - Understand data types and how they work with expressions

For advanced expression features:

- [Function calls](/docs/grafana-cloud/send-data/alloy/get-started/expressions/function_calls) - Transform and compute values using built-in functions
- [Operators](/docs/grafana-cloud/send-data/alloy/get-started/expressions/operators) - Combine and manipulate values using mathematical and logical operators
