「GRAFANA-ALLOY」- config.alloy 配置文件 | 语法 | 学习笔记

认识

文档:https://grafana.com/docs/alloy/latest/get-started/configuration-syntax/

组成

语法 | Syntax | https://grafana.com/docs/alloy/latest/get-started/configuration-syntax/syntax/

注释://

// Pattern for creating a labeled block:
BLOCK_NAME "BLOCK_LABEL" {
  // Block body can contain attributes and nested unlabeled blocks
  IDENTIFIER = EXPRESSION // Attribute

  NESTED_BLOCK_NAME {
    // Nested block body
  }
}

Attributes

以 KV 形式存在,用于个别配置;

Expressions

https://grafana.com/docs/alloy/latest/get-started/configuration-syntax/expressions/

1)用于计算 attribute 的值,支持的形式:例如加减乘除、==、env() 等等
2)export 是指 Component 导出的变量:例如 local.file.password_file.content 等等

Standard library | The standard library is a list of functions you can use in expressions when assigning values to attributes. All standard library functions are pure functions. The functions always return the same output if given the same input. https://grafana.com/docs/alloy/latest/reference/stdlib/

Blocks

1)每对构成块,

Identifiers

  • An identifier in Alloy syntax is valid if it contains one or more UTF-8 letters (A through Z, upper- or lowercase), digits, or underscores. It can’t start with a digit.

性质

Fast\Simple\Debuggable

构建

配置文件 | 格式化 | 校验 | 编辑 | ……

格式化

grafana-agent-flow fmt /etc/grafana-agent-flow.river
grafana-agent-flow fmt /etc/grafana-agent-flow.river –write

编辑器

VS Code

参考

参考官方页面,获得关于配置语法的详细说明。