//https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1 public HttpStrategyClient(IOptions <Config> config, HttpClient httpClient, IHealthResponse healthResponse) { httpClient.BaseAddress = new Uri($"{config.Value.StrategyUrl}"); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); _client = httpClient; _healthResponse = healthResponse; }
private void EnsureExpectedNumberOfNodes(IHealthResponse response) { if (_logstashConfiguration.NodeCount == response.NumberOfNodes) { return; } var message = string.Format("Expected {0} Elasticsearch node(s), saw {1}.", _logstashConfiguration.NodeCount, response.NumberOfNodes); throw new Exception(message); }
private void EnsureNoTimeout(IHealthResponse health) { if (!health.TimedOut) { return; } var message = string.Format("Logstash elastic cluster health check timed out ({0}).", _logstashConfiguration.Timeout); throw new Exception(message); }
private void EnsureNoTimeout(IHealthResponse health) { if (!health.TimedOut) { return; } var message = string.Format( "Elasticsearch cluster health check timed out ({0}).", Timeout); throw new Exception(message); }
private void EnsureClusterIsHealthy(IHealthResponse health) { if (health.Status == "green") { return; } //Clusters with only one node allways have status of "yellow" if ((health.Status == "yellow" && ExpectedNodeCount > 1) || health.Status == "red") { var statusMessage = string.Format("Cluster is unhealthy: \"{0}\". Advise checking cluster if this message is logged again.", health.Status); _logger.Warn(statusMessage); } if (health.NumberOfNodes != ExpectedNodeCount) { var message = string.Format("Cluster should contain {0} nodes, but only has {1}.", ExpectedNodeCount, health.NumberOfNodes); _logger.Warn(message); } }