Ejemplo n.º 1
0
        private void NotifyFailureResult(HealthCheckResult result)
        {
            var failingLayerName = (result.AllResults.FirstOrDefault(r => r.Level >= LogLevel.Error)?.CheckId?.Name ?? "UnknownLayer").Truncate(MaxOpsgenieTagLength);
            var message          = result.Reason.Truncate(MaxOpsgenieMessageLength);

            var request = new OpsGenieCreateAlertRequest(this._settings.ApiKey, message)
            {
                Alias       = "nimator-failure",
                Description = _formatter.Format(result),
                Teams       = new[] { this._settings.TeamName },
                Tags        = new[] { "Nimator", failingLayerName }
            };

            SimpleRestUtils.PostToRestApi(AlertUrl, request);
        }
Ejemplo n.º 2
0
        private void NotifyFailureResult(INimatorResult result)
        {
            var failingLayerName = (result.GetFirstFailedLayerName() ?? "UnknownLayer").Truncate(MaxOpsgenieTagLength);
            var message          = result.Message.Truncate(MaxOpsgenieMessageLength);

            var request = new OpsGenieCreateAlertRequest(this.settings.ApiKey, message)
            {
                Alias       = "nimator-failure",
                Description = result.RenderPlainText(settings.Threshold),
                Teams       = new[] { this.settings.TeamName },
                Tags        = new[] { "Nimator", failingLayerName }
            };

            SimpleRestUtils.PostToRestApi(AlertUrl, request);
        }
Ejemplo n.º 3
0
        public void Notify(INimatorResult result)
        {
            if (settings.DebounceTimeInSecs > 0 && DateTime.Now < dontAlertBefore)
            {
                return;
            }

            if (result.Level >= settings.Threshold)
            {
                var message = new SlackMessage(result, settings.Threshold, settings.SourceEnvironment);

                if (settings.DebounceTimeInSecs > 0)
                {
                    dontAlertBefore = DateTime.Now.AddSeconds(settings.DebounceTimeInSecs);
                    message.AddAttachment("Debouncing messages until at least *" + dontAlertBefore.ToString("yyyy-MM-dd, HH:mm:ss") + "*, even if more problems arise.");
                }

                SimpleRestUtils.PostToRestApi(settings.Url, message);
            }
        }
Ejemplo n.º 4
0
        public void Send([NotNull] HealthCheckResult result)
        {
            Guard.AgainstNull(nameof(result), result);

            if (_settings.DebounceTimeInSecs > 0 && DateTime.Now < _dontAlertBefore)
            {
                return;
            }

            result.Finalize(result.CheckId, r => r.Level >= _settings.Threshold);
            if (result.Level >= _settings.Threshold)
            {
                var message = new SlackMessage(result, _formatter);

                if (_settings.DebounceTimeInSecs > 0)
                {
                    _dontAlertBefore = DateTime.Now.AddSeconds(_settings.DebounceTimeInSecs);
                    message.AddAttachment("Debouncing messages until at least *" + _dontAlertBefore.ToString("yyyy-MM-dd, HH:mm:ss") + "*, even if more problems arise.");
                }

                SimpleRestUtils.PostToRestApi(_settings.Url, message);
            }
        }
Ejemplo n.º 5
0
        private void SendHeartbeat()
        {
            var request = new OpsGenieHeartbeatRequest(this._settings.ApiKey, this._settings.HeartbeatName);

            SimpleRestUtils.PostToRestApi(HeartbeatUrl, request);
        }