<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>local on Grafana Labs</title><link>https://grafana.com/docs/alloy/v1.15/reference/components/local/</link><description>Recent content in local on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/alloy/v1.15/reference/components/local/index.xml" rel="self" type="application/rss+xml"/><item><title>local.file</title><link>https://grafana.com/docs/alloy/v1.15/reference/components/local/local.file/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/reference/components/local/local.file/</guid><content><![CDATA[&lt;h1 id=&#34;localfile&#34;&gt;&lt;code&gt;local.file&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;local.file&lt;/code&gt; exposes the contents of a file on disk to other components.
The file is watched for changes so that its latest content is always exposed.&lt;/p&gt;
&lt;p&gt;The most common use of &lt;code&gt;local.file&lt;/code&gt; is to load secrets (for example, API keys) from files.&lt;/p&gt;
&lt;p&gt;You can specify multiple &lt;code&gt;local.file&lt;/code&gt; components by giving them different labels.&lt;/p&gt;
&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file &amp;#34;&amp;lt;LABEL&amp;gt;&amp;#34; {
  filename = &amp;#34;&amp;lt;FILE_NAME&amp;gt;&amp;#34;
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;p&gt;You can use the following arguments with &lt;code&gt;local.file&lt;/code&gt;:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;filename&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Path of the file on disk to watch.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;detector&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Which file change detector to use, &lt;code&gt;fsnotify&lt;/code&gt; or &lt;code&gt;poll&lt;/code&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;fsnotify&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;is_secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;bool&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Marks the file as containing a &lt;a href=&#34;../../../../get-started/configuration-syntax/expressions/types_and_values/#secrets&#34;&gt;secret&lt;/a&gt;.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;poll_frequency&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How often to poll for file changes.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;1m&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;

&lt;div data-shared=&#34;reference/components/local-file-arguments-text.md&#34;&gt;
            &lt;h3 id=&#34;file-change-detectors&#34;&gt;File change detectors&lt;/h3&gt;
&lt;p&gt;File change detectors detect when the file needs to be re-read from disk. &lt;code&gt;local.file&lt;/code&gt; supports two detectors: &lt;code&gt;fsnotify&lt;/code&gt; and &lt;code&gt;poll&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id=&#34;fsnotify&#34;&gt;&lt;code&gt;fsnotify&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;fsnotify&lt;/code&gt; detector subscribes to filesystem events, which indicate when the watched file is updated.
This detector requires a filesystem that supports events at the operating system level. Network-based filesystems like NFS or FUSE won&amp;rsquo;t work.&lt;/p&gt;
&lt;p&gt;The component re-reads the watched file when a filesystem event is received.
This re-read happens for any filesystem event related to the file, including a permissions change.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fsnotify&lt;/code&gt; also polls for changes to the file with the configured &lt;code&gt;poll_frequency&lt;/code&gt; as a fallback.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;fsnotify&lt;/code&gt; stops receiving filesystem events if the watched file has been deleted, renamed, or moved.
The subscription is re-established on the next poll once the watched file exists again.&lt;/p&gt;
&lt;h4 id=&#34;poll&#34;&gt;&lt;code&gt;poll&lt;/code&gt;&lt;/h4&gt;
&lt;p&gt;The &lt;code&gt;poll&lt;/code&gt; file change detector causes the watched file to be re-read every &lt;code&gt;poll_frequency&lt;/code&gt;, regardless of whether the file changed.&lt;/p&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;local.file&lt;/code&gt; component doesn&amp;rsquo;t support any blocks. You can configure this component with arguments.&lt;/p&gt;
&lt;h2 id=&#34;exported-fields&#34;&gt;Exported fields&lt;/h2&gt;
&lt;p&gt;The following fields are exported and can be referenced by other components:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;content&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;string&lt;/code&gt; or &lt;code&gt;secret&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The contents of the file from the most recent read.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;content&lt;/code&gt; field has the &lt;code&gt;secret&lt;/code&gt; type only if the &lt;code&gt;is_secret&lt;/code&gt; argument is true.&lt;/p&gt;
&lt;p&gt;You can use &lt;code&gt;local.file.LABEL.content&lt;/code&gt; to access the contents of the file.&lt;/p&gt;
&lt;h2 id=&#34;component-health&#34;&gt;Component health&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file&lt;/code&gt; is reported as healthy whenever if the watched file was read successfully.&lt;/p&gt;
&lt;p&gt;Failing to read the file whenever an update is detected (or after the poll period elapses) causes the component to be reported as unhealthy.
When unhealthy, exported fields is kept at the last healthy value.
The read error is exposed as a log message and in the debug information for the component.&lt;/p&gt;
&lt;h2 id=&#34;debug-information&#34;&gt;Debug information&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file&lt;/code&gt; doesn&amp;rsquo;t expose any component-specific debug information.&lt;/p&gt;
&lt;h2 id=&#34;debug-metrics&#34;&gt;Debug metrics&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;local_file_timestamp_last_accessed_unix_seconds&lt;/code&gt; (gauge): The timestamp, in Unix seconds, that the file was last successfully accessed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;p&gt;The following example shows a simple &lt;code&gt;local.file&lt;/code&gt; configuration that watches a passwords text file and uses the exported content field.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file &amp;#34;secret_key&amp;#34; {
  filename  = &amp;#34;/var/secrets/password.txt&amp;#34;
  is_secret = true
}
grafana_cloud.stack &amp;#34;receivers&amp;#34; {
  stack_name = &amp;#34;mystack&amp;#34;
  token = local.file.secret_key.content
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
]]></content><description>&lt;h1 id="localfile">&lt;code>local.file&lt;/code>&lt;/h1>
&lt;p>&lt;code>local.file&lt;/code> exposes the contents of a file on disk to other components.
The file is watched for changes so that its latest content is always exposed.&lt;/p></description></item><item><title>local.file_match</title><link>https://grafana.com/docs/alloy/v1.15/reference/components/local/local.file_match/</link><pubDate>Mon, 30 Mar 2026 15:47:22 +0000</pubDate><guid>https://grafana.com/docs/alloy/v1.15/reference/components/local/local.file_match/</guid><content><![CDATA[&lt;h1 id=&#34;localfile_match&#34;&gt;&lt;code&gt;local.file_match&lt;/code&gt;&lt;/h1&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; discovers files on the local filesystem using glob patterns and the &lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;doublestar&lt;/a&gt; library.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Use the built-in &lt;a href=&#34;../../loki/loki.source.file/#file_match&#34;&gt;&lt;code&gt;file_match&lt;/code&gt;&lt;/a&gt; block in &lt;code&gt;loki.source.file&lt;/code&gt; whenever possible.
This provides better performance by integrating file discovery directly into the component, eliminating the overhead of a separate component.
The performance benefit is especially noticeable in environments with many files to watch.&lt;/p&gt;
&lt;p&gt;Use the &lt;code&gt;local.file_match&lt;/code&gt; component only when you need to share discovered targets across multiple components, reuse file discovery results in different parts of your configuration, or accept targets from other discovery components, for example,  &lt;code&gt;discovery.relabel&lt;/code&gt; before file matching.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file_match &amp;#34;LABEL&amp;#34; {
  path_targets = [{&amp;#34;__path__&amp;#34; = DOUBLESTAR_PATH}]
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;arguments&#34;&gt;Arguments&lt;/h2&gt;
&lt;p&gt;You can use the following arguments with &lt;code&gt;local.file_match&lt;/code&gt;:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Default&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;path_targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Targets to expand; looks for glob patterns on the  &lt;code&gt;__path__&lt;/code&gt; and &lt;code&gt;__path_exclude__&lt;/code&gt; keys.&lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;ignore_older_than&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;Ignores files with modification times before this duration.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;0s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;sync_period&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;duration&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;How often to sync filesystem and targets.&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;&amp;quot;10s&amp;quot;&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;no&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h3 id=&#34;path_targets-structure&#34;&gt;&lt;code&gt;path_targets&lt;/code&gt; structure&lt;/h3&gt;
&lt;p&gt;Each target in &lt;code&gt;path_targets&lt;/code&gt; is a map that can contain the following keys:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Key&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
              &lt;th&gt;Required&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;__path__&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;doublestar&lt;/a&gt; glob pattern specifying which files to discover.&lt;/td&gt;
              &lt;td&gt;Yes&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;__path_exclude__&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;doublestar&lt;/a&gt; glob pattern specifying which files to exclude from the &lt;code&gt;__path__&lt;/code&gt; matches.&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;em&gt;additional keys&lt;/em&gt;&lt;/td&gt;
              &lt;td&gt;Any other labels to attach to discovered files. The component preserves these labels in the exported targets.&lt;/td&gt;
              &lt;td&gt;No&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;The &lt;code&gt;__path__&lt;/code&gt; field uses &lt;a href=&#34;https://github.com/bmatcuk/doublestar&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;doublestar&lt;/a&gt; style glob patterns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/tmp/**/*.log&lt;/code&gt; matches all subdirectories of &lt;code&gt;tmp&lt;/code&gt; and include any files that end in &lt;code&gt;*.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/tmp/apache/*.log&lt;/code&gt; matches only files in &lt;code&gt;/tmp/apache/&lt;/code&gt; that end in &lt;code&gt;*.log&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/tmp/**&lt;/code&gt; matches all subdirectories of &lt;code&gt;tmp&lt;/code&gt;, &lt;code&gt;tmp&lt;/code&gt; itself, and all files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/tmp/*.{log,txt,json}&lt;/code&gt; matches files with &lt;code&gt;.log&lt;/code&gt;, &lt;code&gt;.txt&lt;/code&gt;, or &lt;code&gt;.json&lt;/code&gt; extensions in &lt;code&gt;/tmp/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/var/log/{nginx,apache}/*.log&lt;/code&gt; matches &lt;code&gt;.log&lt;/code&gt; files in either the &lt;code&gt;nginx&lt;/code&gt; or &lt;code&gt;apache&lt;/code&gt; subdirectories.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; doesn&amp;rsquo;t ignore files when you set &lt;code&gt;ignore_older_than&lt;/code&gt; to the default, &lt;code&gt;0s&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;When you provide &lt;code&gt;__path_exclude__&lt;/code&gt;, the component excludes any files matching the &lt;code&gt;__path__&lt;/code&gt; pattern that also match the &lt;code&gt;__path_exclude__&lt;/code&gt; pattern from the exported list.&lt;/p&gt;
&lt;p&gt;The component preserves any additional labels you provide in the &lt;code&gt;path_targets&lt;/code&gt; map and includes them in the exported targets alongside the discovered paths.
This enables you to add metadata such as service names, instance identifiers, or other contextual information to the discovered files.&lt;/p&gt;
&lt;h2 id=&#34;blocks&#34;&gt;Blocks&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;local.file_match&lt;/code&gt; component doesn&amp;rsquo;t support any blocks. You can configure this component with arguments.&lt;/p&gt;
&lt;h2 id=&#34;exported-fields&#34;&gt;Exported fields&lt;/h2&gt;
&lt;p&gt;The following fields are exported and can be referenced by other components:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;code&gt;targets&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;&lt;code&gt;list(map(string))&lt;/code&gt;&lt;/td&gt;
              &lt;td&gt;The set of targets discovered from the filesystem.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;p&gt;Each target includes the following labels:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;__path__&lt;/code&gt;: Absolute path to the discovered file.&lt;/li&gt;
&lt;li&gt;All additional labels from the corresponding entry in &lt;code&gt;path_targets&lt;/code&gt; with original values preserved.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;component-health&#34;&gt;Component health&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; is only reported as unhealthy when given an invalid configuration.
In those cases, exported fields retain their last healthy values.&lt;/p&gt;
&lt;h2 id=&#34;debug-information&#34;&gt;Debug information&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; doesn&amp;rsquo;t expose any component-specific debug information.&lt;/p&gt;
&lt;h2 id=&#34;debug-metrics&#34;&gt;Debug metrics&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; doesn&amp;rsquo;t expose any component-specific debug metrics.&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;The following examples show you how to use &lt;code&gt;local.file_match&lt;/code&gt; to find and send log files to Loki&lt;/p&gt;
&lt;h3 id=&#34;send-tmplogslog-files-to-loki&#34;&gt;Send &lt;code&gt;/tmp/logs/*.log&lt;/code&gt; files to Loki&lt;/h3&gt;
&lt;p&gt;This example discovers all files and folders under &lt;code&gt;/tmp/logs&lt;/code&gt; except for files in the &lt;code&gt;/tmp/logs/excluded&lt;/code&gt; directory.
&lt;code&gt;loki.source.file.files&lt;/code&gt; targets use absolute paths in the &lt;code&gt;__path__&lt;/code&gt; label.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file_match &amp;#34;tmp&amp;#34; {
  path_targets = [{&amp;#34;__path__&amp;#34; = &amp;#34;/tmp/logs/**/*.log&amp;#34;, &amp;#34;__path_exclude__&amp;#34; = &amp;#34;/tmp/logs/excluded/*.log&amp;#34;}]
}

loki.source.file &amp;#34;files&amp;#34; {
  targets    = local.file_match.tmp.targets
  forward_to = [loki.write.endpoint.receiver]
}

loki.write &amp;#34;endpoint&amp;#34; {
  endpoint {
      url = &amp;lt;LOKI_URL&amp;gt;
      basic_auth {
          username = &amp;lt;USERNAME&amp;gt;
          password = &amp;lt;PASSWORD&amp;gt;
      }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;LOKI_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL of the Loki server to send logs to.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;USERNAME&amp;gt;&lt;/code&gt;&lt;/em&gt;: The username to use for authentication to the Loki API.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;PASSWORD&amp;gt;&lt;/code&gt;&lt;/em&gt;: The password to use for authentication to the Loki API.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;send-files-with-additional-labels&#34;&gt;Send files with additional labels&lt;/h3&gt;
&lt;p&gt;This example shows how to include additional labels with discovered files.
The component preserves the additional labels in the exported targets and you can use them for filtering or enrichment.
It attaches the additional labels &lt;code&gt;instance&lt;/code&gt;, &lt;code&gt;job&lt;/code&gt;, and &lt;code&gt;service&lt;/code&gt; to each discovered file.
Downstream components like &lt;code&gt;loki.source.file&lt;/code&gt; can access these labels for processing and enrichment.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file_match &amp;#34;labeled_logs&amp;#34; {
  path_targets = [
    {
      &amp;#34;__path__&amp;#34;    = &amp;#34;/var/log/apache2/*.log&amp;#34;,
      &amp;#34;__address__&amp;#34; = &amp;#34;localhost&amp;#34;,
      &amp;#34;instance&amp;#34;    = &amp;#34;web-server-01&amp;#34;, 
      &amp;#34;job&amp;#34;         = &amp;#34;apache&amp;#34;,
      &amp;#34;service&amp;#34;     = &amp;#34;web&amp;#34;,
    },
    {
      &amp;#34;__path__&amp;#34;       = &amp;#34;/var/log/nginx/*.log&amp;#34;,
      &amp;#34;__path_exclude__&amp;#34; = &amp;#34;/var/log/nginx/*.gz&amp;#34;,
      &amp;#34;__address__&amp;#34;    = &amp;#34;localhost&amp;#34;,
      &amp;#34;instance&amp;#34;       = &amp;#34;web-server-01&amp;#34;,
      &amp;#34;job&amp;#34;            = &amp;#34;nginx&amp;#34;, 
      &amp;#34;service&amp;#34;        = &amp;#34;web&amp;#34;,
    },
  ]
}

loki.source.file &amp;#34;web_logs&amp;#34; {
  targets    = local.file_match.labeled_logs.targets
  forward_to = [loki.write.endpoint.receiver]
}

loki.write &amp;#34;endpoint&amp;#34; {
  endpoint {
    url = &amp;#34;&amp;lt;LOKI_URL&amp;gt;&amp;#34;
    basic_auth {
      username = &amp;#34;&amp;lt;USERNAME&amp;gt;&amp;#34;
      password = &amp;#34;&amp;lt;PASSWORD&amp;gt;&amp;#34;
    }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;LOKI_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL of the Loki server to send logs to.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;USERNAME&amp;gt;&lt;/code&gt;&lt;/em&gt;: The username to use for authentication to the Loki API.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;PASSWORD&amp;gt;&lt;/code&gt;&lt;/em&gt;: The password to use for authentication to the Loki API.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;match-multiple-patterns&#34;&gt;Match multiple patterns&lt;/h3&gt;
&lt;p&gt;This example shows how to use the &lt;code&gt;{a,b,c}&lt;/code&gt; pattern syntax to match multiple file extensions, multiple directories, and exclude multiple file types in a single configuration.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;local.file_match &amp;#34;logs&amp;#34; {
  path_targets = [
    // Match .log, .txt, and .json files from nginx, apache, or caddy directories
    // Exclude compressed and backup files
    {
      &amp;#34;__path__&amp;#34;         = &amp;#34;/var/log/{nginx,apache,caddy}/*.{log,txt,json}&amp;#34;,
      &amp;#34;__path_exclude__&amp;#34; = &amp;#34;/var/log/{nginx,apache,caddy}/*.{gz,zip,bak,old}&amp;#34;,
      &amp;#34;job&amp;#34;              = &amp;#34;webserver&amp;#34;,
    },
  ]
}

loki.source.file &amp;#34;logs&amp;#34; {
  targets    = local.file_match.logs.targets
  forward_to = [loki.write.endpoint.receiver]
}

loki.write &amp;#34;endpoint&amp;#34; {
  endpoint {
    url = &amp;#34;&amp;lt;LOKI_URL&amp;gt;&amp;#34;
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&#34;send-kubernetes-pod-logs-to-loki&#34;&gt;Send Kubernetes Pod logs to Loki&lt;/h3&gt;
&lt;p&gt;This example finds all the logs on Pods and monitors them.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Alloy&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-alloy&#34;&gt;discovery.kubernetes &amp;#34;k8s&amp;#34; {
  role = &amp;#34;pod&amp;#34;
}

discovery.relabel &amp;#34;k8s&amp;#34; {
  targets = discovery.kubernetes.k8s.targets

  rule {
    source_labels = [&amp;#34;__meta_kubernetes_namespace&amp;#34;, &amp;#34;__meta_kubernetes_pod_label_name&amp;#34;]
    target_label  = &amp;#34;job&amp;#34;
    separator     = &amp;#34;/&amp;#34;
  }

  rule {
    source_labels = [&amp;#34;__meta_kubernetes_pod_uid&amp;#34;, &amp;#34;__meta_kubernetes_pod_container_name&amp;#34;]
    target_label  = &amp;#34;__path__&amp;#34;
    separator     = &amp;#34;/&amp;#34;
    replacement   = &amp;#34;/var/log/pods/*$1/*.log&amp;#34;
  }
}

local.file_match &amp;#34;pods&amp;#34; {
  path_targets = discovery.relabel.k8s.output
}

loki.source.file &amp;#34;pods&amp;#34; {
  targets = local.file_match.pods.targets
  forward_to = [loki.write.endpoint.receiver]
}

loki.write &amp;#34;endpoint&amp;#34; {
  endpoint {
      url = &amp;#34;&amp;lt;LOKI_URL&amp;gt;&amp;#34;
      basic_auth {
          username = &amp;#34;&amp;lt;USERNAME&amp;gt;&amp;#34;
          password = &amp;#34;&amp;lt;PASSWORD&amp;gt;&amp;#34;
      }
  }
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Replace the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;LOKI_URL&amp;gt;&lt;/code&gt;&lt;/em&gt;: The URL of the Loki server to send logs to.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;USERNAME&amp;gt;&lt;/code&gt;&lt;/em&gt;: The username to use for authentication to the Loki API.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;&lt;code&gt;&amp;lt;PASSWORD&amp;gt;&lt;/code&gt;&lt;/em&gt;: The password to use for authentication to the Loki API.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- START GENERATED COMPATIBLE COMPONENTS --&gt;
&lt;h2 id=&#34;compatible-components&#34;&gt;Compatible components&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; can accept arguments from the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that export &lt;a href=&#34;../../../compatibility/#targets-exporters&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;local.file_match&lt;/code&gt; has exports that can be consumed by the following components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Components that consume &lt;a href=&#34;../../../compatibility/#targets-consumers&#34;&gt;Targets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Connecting some components may not be sensible or components may require further configuration to make the connection work correctly.
Refer to the linked documentation for more details.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;!-- END GENERATED COMPATIBLE COMPONENTS --&gt;
]]></content><description>&lt;h1 id="localfile_match">&lt;code>local.file_match&lt;/code>&lt;/h1>
&lt;p>&lt;code>local.file_match&lt;/code> discovers files on the local filesystem using glob patterns and the &lt;a href="https://github.com/bmatcuk/doublestar" target="_blank" rel="noopener noreferrer">doublestar&lt;/a> library.&lt;/p>
&lt;div class="admonition admonition-note">&lt;blockquote>&lt;p class="title text-uppercase">Note&lt;/p>&lt;p>Use the built-in &lt;a href="../../loki/loki.source.file/#file_match">&lt;code>file_match&lt;/code>&lt;/a> block in &lt;code>loki.source.file&lt;/code> whenever possible.
This provides better performance by integrating file discovery directly into the component, eliminating the overhead of a separate component.
The performance benefit is especially noticeable in environments with many files to watch.&lt;/p></description></item></channel></rss>