Skip to content

authentication on the metrics endpoint #100

@impactmrj

Description

@impactmrj

Just testing the metrics.net library, curious if one can put authentication on the metrics endpoint? Below is our snippet in the configuration() method. What am I missing? My controller is expecting basic authentication but the metrics endpoint is allowing me to go to it.

        appBuilder.Use(typeof(AuthenticationMiddleware));
        appBuilder.UseCors(CorsOptions.AllowAll);

        Metric.Config
         .WithAllCounters()
         //.WithReporting(r => r.WithConsoleReport(TimeSpan.FromSeconds(30)))
         .WithOwin(m => appBuilder.Use(m), cfg => cfg
             .WithRequestMetricsConfig(c => c.WithAllOwinMetrics(), new[]
             {
                new Regex("(?i)^sampleignore"),
                new Regex("(?i)^metrics"),
                new Regex("(?i)^health"),
                new Regex("(?i)^json")
             })
             .WithMetricsEndpoint()
         );

        HttpConfiguration config = new HttpConfiguration();
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
            name: "DefaultApi",
            routeTemplate: "api/{controller}/{id}",
            defaults: new { id = RouteParameter.Optional }
        );

        appBuilder.UseWebApi(config);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions