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

import.git unable to import from Azure DevOps Repository #2924

Open
begamnify opened this issue Mar 6, 2025 · 0 comments
Open

import.git unable to import from Azure DevOps Repository #2924

begamnify opened this issue Mar 6, 2025 · 0 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation type/docs Docs Squad label across all Grafana Labs repos

Comments

@begamnify
Copy link

begamnify commented Mar 6, 2025

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

  1. Create an Azure DevOps repository with the custom component to be imported..
  2. Create a configuration similar to the one attached below.
  3. 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`
@begamnify begamnify added the bug Something isn't working label Mar 6, 2025
@dehaansa dehaansa added documentation Improvements or additions to documentation type/docs Docs Squad label across all Grafana Labs repos labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation type/docs Docs Squad label across all Grafana Labs repos
Projects
None yet
Development

No branches or pull requests

2 participants