Description
What's wrong?
While building an Alloy configuration which needs to get a custom component from an Azure DevOps repository, I was unable to successfully retrieve the custom component via the import.git
component, despite being authorized correctly.
Having dug a few resources, I learnt that the git implementation used by Alloy (namely go-git) had some issues with implementing multi_ack which is leveraged by Azure DevOps repositories This was discussed in go-git issue 64. The subject is beyond my area of expertise, but given that go-git contributors implemented a fix with the following caveats tells me that services using go-git need to go through a few extra hurdles to work well with repositories leveraging multi_ack.
@dehaansa was kind enough to share an alternative approach using import.http
instead which worked like a charm using Azure's APIs to get the file from the repository via REST as seen below:
import.http "test" {
url = "[https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/filecontents?serviceEndpointId={serviceEndpointId}&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=7.1](https://dev.azure.com/%7Borganization%7D/%7Bproject%7D/_apis/sourceProviders/%7BproviderName%7D/filecontents?serviceEndpointId={serviceEndpointId}&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=7.1)"
client {
basic_auth {
username = "<Username>"
password = "<Password>"
}
}
(important to use tfsgit
as a source provider due to this issue with the API.)
But....it would be nice if this issue is addressed for us ADO users! Should definitely be noted in the documentation as well as it would save people a lot of head scratching!
Steps to reproduce
- Create an Azure DevOps repository with the custom component to be imported..
- Create a configuration similar to the one attached below.
- Attempt to start Alloy.
System information
Docker WSL (Ubuntu)
Software version
v1.7.1
Configuration
import.git "sampled_collector" {
repository = "https://dev.azure.com/{org}/{project}/_git/{repo}"
revision = "main"
path = "alloy/client-components/gt-test-sampled-collector.alloy"
pull_frequency = "60s"
basic_auth {
username = "{PAT_TOKEN}"
password = ""
}
}
otelcol.receiver.otlp "default" {
grpc {}
output {
metrics = [otelcol.processor.batch.default.input]
logs = [otelcol.processor.batch.default.input]
traces = [sampled_collector.client_sampler.default.processor_input]
}
}
sampled_collector.client_sampler "default" {
traces_output = otelcol.processor.batch.default.input
}
otelcol.processor.batch "default" {
output {
metrics = [otelcol.exporter.otlphttp.default.input]
logs = [otelcol.exporter.otlphttp.default.input]
traces = [otelcol.exporter.otlphttp.default.input]
}
}
otelcol.auth.basic "default" {
username = sys.env("GRAFANA_OTLP_USERNAME")
password = sys.env("GRAFANA_OTLP_PASSWORD")
}
otelcol.exporter.otlphttp "default" {
client {
endpoint = sys.env("GRAFANA_OTLP_ENDPOINT")
auth = otelcol.auth.basic.default.handler
}
}
Logs
Error: /etc/alloy/config.alloy:36:1: Failed to evaluate node for config block: updating component: failed to download repository "https://<org>@dev.azure.com/<org>/<project>/_git/infra": unexpected client error: unexpected requesting "https://<org>@dev.azure.com/<org>/<project>/_git/infra/git-upload-pack" status code: 400`