serilog-contrib / serilog-sinks-grafana-loki

A Serilog sink sending log events to Grafana Loki
MIT License
201 stars 30 forks source link

Strugling pushing logs to a hosted Loki Instance #245

Closed Triskae closed 10 months ago

Triskae commented 10 months ago

Which version of Serilog.Sinks.Grafana.Loki are you using?

V8

Which version of .NET are you using?

net6.0

Describe the bug

Hello,

I'm struggling pushing logs to my cloud provider Loki instance.

I configured everything as state in the readme, but not succeeding with sending logs to Loki. I managed to make it work with the cloud provider python example code here

Do you support sending auth like this: https://api_key:theapikeyhier@logs.cockpit.fr-par.scw.cloud ? It seems not because, the Serilog.Debugging.SelfLog.Enable(Console.Error); is telling me that there's a 401 error. Here is my code, do you see something wrong ?

public static IServiceCollection SetupSerilog(this IServiceCollection services, ConfigurationManager configuration)
    {
        var appLabel = new LokiLabel { Key = "Application", Value = "AppStaging" };
        var stagingLabel = new LokiLabel { Key = "Environment", Value = "Staging" };
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Warning()
            .Enrich.FromLogContext()
            .WriteTo.Console()
            .WriteTo.GrafanaLoki(
                "https://api_key:theapikey@logs.cockpit.fr-par.scw.cloud",
                new[] { appLabel, stagingLabel }, new[] { "Application", "Environment" })
            .Enrich.WithProperty("Application", "AppStaging")
            .Enrich.WithProperty("Environment", "Staging")
            .CreateLogger();

        return services;
    }

To Reproduce

Configure a .NET 6 API to use Serilog and serilog-sinks-grafana-loki. Configure it with Scaleway way to auth.

Expected behavior

To push logs as the python example.

Log/SelfLog output or exception with stacktrace

No response

Application or code sample, which could be used to reproduce a bug

No response

Additional context

No response

I have read the documentation

mishamyte commented 10 months ago

Hi @Triskae,

Please, check #24, I believe it will be useful

Triskae commented 10 months ago

WTF, I'm juste realizing that the scaleway documentation is using api_key:oass, api_key being the username ..... So dumb, I'm gonna try rn. Thanks @mishamyte

Triskae commented 10 months ago

I spent all the afternoon digging this ... Working now, thanks a lot ! @mishamyte

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue.