Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module library path parameter #828

Open
jkroepke opened this issue May 11, 2024 · 5 comments
Open

Add module library path parameter #828

jkroepke opened this issue May 11, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@jkroepke
Copy link
Contributor

Request

I would like to use https://grafana.com/docs/alloy/latest/reference/config-blocks/import.file/ without define a full qualified file path for filename.

Use case

Cross OS compatibility. I would like to use the same configuration under windows and linux. However this is not possible, because the location of the config files is different.

With load paths (as CLI flag), I can define a desired location for additional configurations files across multiple systems.

Similar to the PATH environment variable on UNIX systems for looking up binaries.

@jkroepke jkroepke added the enhancement New feature or request label May 11, 2024
@jkroepke jkroepke changed the title Add file load paths parameter Add module library path parameter May 11, 2024
@wildum
Copy link
Contributor

wildum commented May 13, 2024

Hello, thanks for the enhancement request :) We are planning to add relative path support for import.file which may solve your problem:

If the relative path from the main config to the module is the same in both environments, then you would be able to do filename = path_join(module_path, "relative/path") with module_path (new stdlib addition) = path to the root config.

For now, maybe a workaround can be to use env variables to specify different paths for the different envs? https://grafana.com/docs/alloy/latest/reference/stdlib/env/

@jkroepke
Copy link
Contributor Author

Does it also work, if I'm calling import.file outside of an module?

In my scenario, I have import.file at root scope.

@wildum
Copy link
Contributor

wildum commented May 13, 2024

yes it also works, fyi we defined the terminology as follows:

Module: A unit of Alloy configuration, with its own set of independent configuration blocks and instantiated components. A single module may be represented by multiple files.

Main configuration: The module which is directly loaded by alloy run

So the main config is also a module and its module_path is the path that you give in the alloy run command

@jkroepke
Copy link
Contributor Author

jkroepke commented May 13, 2024

So the main config is also a module and its module_path is the path that you give in the alloy run command

Perfect! Did you also consider to add something like root_path which is always pointing the the path where the initial config is? It could helpful if file are living aside from the default config, and I would like to reference them from a import.http module.

@wildum
Copy link
Contributor

wildum commented May 13, 2024

We didn't but that's a good idea. I will suggest it to the team and if they're fine with it I could add it as a follow up of the relative path PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants