예제 #1
0
        public async Task WriteToSeq(JsonSyslogMessage message, int delay = 0)
        {
            if (message.Invalid)
            {
                Logger.Warning("Skipping incomplete/invalid message. [{0}]", message.RawMessage);
                return;
            }

            await Task.Delay(Math.Min(delay, 60000));

            ExceptionDispatchInfo capturedException = null;

            try
            {
                await this.WriteMessage(message).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                capturedException = ExceptionDispatchInfo.Capture(ex);
            }

            if (capturedException != null)
            {
                this.retryCount++;
                Logger.Warning("Couldn't write to SEQ. Retry Count:[{0}] Exception: [{1}]", this.retryCount, capturedException.SourceException.Message);
                await this.WriteToSeq(message, (int)Math.Pow(100, this.retryCount));
            }
        }
예제 #2
0
        private async Task WriteMessage(JsonSyslogMessage message)
        {
            using (var http = new HttpClient())
            {
                using (var content = new StringContent("{\"events\":[" + message.ToString() + "]}", Encoding.UTF8, "application/json"))
                {
                    var response = await http.PostAsync(new Uri(Configuration.SeqServer, "api/events/raw"), content).ConfigureAwait(false);

                    response.EnsureSuccessStatusCode();
                }
            }
        }
예제 #3
0
        public void CanParseThing()
        {
            var thing = new JsonSyslogMessage("78 2015-02-10T19:26:01.889893+00:00 mongo-monitor CROND  (ec2-user) CMD (/home/ec2-user/bin/run_node_metrics)");

            //Program.WriteToSeq(thing).Wait();
        }