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

QUESTION: Dynamic addition on endpoints does not reflect in UI #565

Open
kisalay19 opened this issue Jun 19, 2020 · 2 comments
Open

QUESTION: Dynamic addition on endpoints does not reflect in UI #565

kisalay19 opened this issue Jun 19, 2020 · 2 comments
Labels

Comments

@kisalay19
Copy link

This is more of a help needed for my implementation. As per a port the "HealthChecksDb" dbcontext has been made public and is now accessible to make changes at runtime. Below is my code setup. I am able to refresh the Configrations DbSet but the same does not reflect in the UI

Startup.cs ConfigureServices(......)
{
    ...
    services.AddDbContext<APIHealthCheckContext>(options => options.UseInMemoryDatabase("HealthCheckMock")); //Local context to get the list of configured endpoints

    services.AddDbContext<HealthChecksDb>(options => options.UseInMemoryDatabase("HealthCheckMock"));

    services.AddHealthChecksUI(setupSettings: setup =>
                {
                    setup.SetEvaluationTimeInSeconds(300);
                    setup.SetMinimumSecondsBetweenFailureNotifications(300);
                }).AddInMemoryStorage(options => { options.UseInMemoryDatabase("HealthCheckMock"); });
    ...
}

Startup.cs Configure(......)
{
    ...
    app.UseHealthChecksUI(setup =>
            {
                setup.UIPath = "/healthcheckdashboard-ui";
                setup.ApiPath = "/healthcheckdashboard-api";
            });
    ...
}

Controller
public ActionResult TrackEndpoints([FromQuery] string ApiVersion, [FromQuery] string ApiName)
        {
            var endpoints = _processor.UpdateEndpoints(ApiVersion, ApiName); //Business layer which gets the endpoints based on the version and name filter

            if (endpoints?.Count > 0)
            {
                List<HealthCheckConfiguration> endpointsList = new List<HealthCheckConfiguration>();

                foreach(var endpoint in endpoints.ToList())
                {
                    endpointsList.Add(new HealthCheckConfiguration
                    {
                        Name = string.Join(' ', endpoint.APIName, endpoint.Version),
                        Uri = endpoint.BaseURL
                    });
                }

                _context.Configurations.RemoveRange(_context.Configurations);
                _context.SaveChangesAsync();
                _context.Configurations.AddRangeAsync(endpointsList);
                _context.SaveChangesAsync();
                return Redirect("/healthcheckdashboard-ui");
            }
            else
                return NotFound("No API found based on the filters. Please resend");            
        }

In local debug I see that the data in the context with respect to Configurations is getting updated but the same is not reflecting when the request is redirected to UI endpoints.

Can anyone help what I am doing wrong here. Thanks in advance :)

@kisalay19 kisalay19 changed the title Dynamic addition on endpoints does not reflect in UI QUESTION: Dynamic addition on endpoints does not reflect in UI Jul 2, 2020
@kisalay19
Copy link
Author

Did anyone get a change to look into my query :)

@CarlosLanderas
Copy link
Contributor

@kilasay19, take a look to our docker image that adds and removes endpoints on the fly when receives requests from the operator. Be sure you are using an updated UI version package

https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/blob/master/build/docker-images/HealthChecks.UI.Image/PushService/HealthChecksPushService.cs

@sungam3r sungam3r added the UI label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants