---
title: "import.git | Grafana Agent documentation"
description: "Learn about the import.git configuration block"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# import.git

The `import.git` block imports custom components from a Git repository and exposes them to the importer. `import.git` blocks must be given a label that determines the namespace where custom components are exposed.

## Usage

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
import.git "NAMESPACE" {
  repository = "GIT_REPOSTORY"
  path       = "PATH_TO_MODULE"
}
```

## Arguments

The following arguments are supported:

Expand table

| Name             | Type       | Description                                             | Default  | Required |
|------------------|------------|---------------------------------------------------------|----------|----------|
| `repository`     | `string`   | The Git repository address to retrieve the module from. |          | yes      |
| `revision`       | `string`   | The Git revision to retrieve the module from.           | `"HEAD"` | no       |
| `path`           | `string`   | The path in the repository where the module is stored.  |          | yes      |
| `pull_frequency` | `duration` | The frequency to pull the repository for updates.       | `"60s"`  | no       |

The `repository` attribute must be set to a repository address that would be recognized by Git with a `git clone REPOSITORY_ADDRESS` command, such as `https://github.com/grafana/agent.git`.

You must set the `repository` attribute to a repository address that Git would recognize with a `git clone REPOSITORY_ADDRESS` command, such as `https://github.com/grafana/agent.git`.

When provided, the `revision` attribute must be set to a valid branch, tag, or commit SHA within the repository.

You must set the `path` attribute to a path accessible from the repository’s root. It can either be a River file such as `FILE_NAME.river` or `DIR_NAME/FILE_NAME.river` or a directory containing River files such as `DIR_NAME` or `.` if the River files are stored at the root of the repository.

If `pull_frequency` isn’t `"0s"`, the Git repository is pulled for updates at the frequency specified. If it’s set to `"0s"`, the Git repository is pulled once on init.

> Warning
> 
> Pulling hosted Git repositories too often can result in throttling.

## Blocks

The following blocks are supported inside the definition of `import.git`:

Expand table

| Hierarchy   | Block                            | Description                                                 | Required |
|-------------|----------------------------------|-------------------------------------------------------------|----------|
| basic\_auth | [basic\_auth](#basic_auth-block) | Configure basic\_auth for authenticating to the repository. | no       |
| ssh\_key    | [ssh\_key](#ssh_key-block)       | Configure an SSH Key for authenticating to the repository.  | no       |

### basic\_auth block

Expand table

| Name            | Type     | Description                              | Default | Required |
|-----------------|----------|------------------------------------------|---------|----------|
| `password_file` | `string` | File containing the basic auth password. |         | no       |
| `password`      | `secret` | Basic auth password.                     |         | no       |
| `username`      | `string` | Basic auth username.                     |         | no       |

`password` and `password_file` are mutually exclusive, and only one can be provided inside a `basic_auth` block.

### ssh\_key block

Expand table

| Name         | Type     | Description                       | Default | Required |
|--------------|----------|-----------------------------------|---------|----------|
| `username`   | `string` | SSH username.                     |         | yes      |
| `key`        | `secret` | SSH private key.                  |         | no       |
| `key_file`   | `string` | SSH private key path.             |         | no       |
| `passphrase` | `secret` | Passphrase for SSH key if needed. |         | no       |

## Examples

This example imports custom components from a Git repository and uses a custom component to add two numbers:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
import.git "math" {
  repository = "https://github.com/wildum/module.git"
  revision   = "master"
  path       = "math.river"
}

math.add "default" {
  a = 15
  b = 45
}
```

This example imports custom components from a directory in a Git repository and uses a custom component to add two numbers:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
import.git "math" {
  repository = "https://github.com/wildum/module.git"
  revision   = "master"
  path       = "modules"
}

math.add "default" {
  a = 15
  b = 45
}
```
