Search code examples
.net-coremasstransithealth-check

How to change the default tag in the health check user interface?


I want to change the tags, when I check the health of Rabbitmq, masstransit puts these tags by default.

health Check UI Pic

I also want to change the name HealthCheck Name

  builder.Services.AddMassTransit(configure =>
        {
            configure.AddConsumer<RabbitMqConsumer>();
            configure.UsingRabbitMq((context, cfg) =>
            {
                cfg.Host($"{messageBroker.Protocol}://{messageBroker.Host}:{messageBroker.Port}", cfgHost =>
                {
                    cfgHost.Username(messageBroker.UserName);
                    cfgHost.Password(messageBroker.Password);
                });
                cfg.ReceiveEndpoint(queueName: $"{messageBroker.Name}-HealthCheck", config =>
                {
                    config.ConfigureConsumer<RabbitMqConsumer>(context);
                });
            });
        });

Solution

  • You can change the health check options when configuring MassTransit:

    services.AddMassTransit(x =>
    {
        x.ConfigureHealthCheckOptions(options =>
        {
            options.Name = "your special name";
            options.Tags.Add("your tag");
        });
    });