Beispiel #1
1
        /// <summary>
        /// Creates a new Nulunk instance. 
        /// </summary>
        public Nulunk(string sourceType = "nulunk", int forceFlushCount = 100)
        {
            _cqueue = new ConcurrentQueue<string>();
            _args = new Args();
            Command cli = Command.Splunk("search");
            _service = Service.Connect(cli.Opts);
            _receiver = new Receiver(_service);

            _args.Add("sourcetype", sourceType);
            _forceFlushCount = forceFlushCount;
        }
        public bool SendMessage(string message, string index = "main", string host = "localhost", 
            string source="dynaTrace", string sourcetype = "dynatrace/xml")
        {
            if (!connected) return false;

            Receiver splunkReceiver = new Receiver(service);
            
            var args = new Args();

            args.Add("host", host);
            args.Add("source", source);
            args.Add("sourcetype", sourcetype);

            splunkReceiver.Submit(index, args, message);

            return true;
        }
Beispiel #3
0
        protected override void EmitBatch(IEnumerable<LogEvent> events)
        {
            //TODO: Create formatter possibly format with following
            //TODO: Investigate AsynEmit

            _service.Login(_connectionInfo.UserName, _connectionInfo.Password);

            var receiver = new Receiver(_service);
            receiver.Attach(_receiveSubmitArgs);

            foreach (var logEvent in events)
            {
                dynamic data = new {Timestamp = logEvent.Timestamp, Level = logEvent.Level, Data = logEvent.RenderMessage()};
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(data, new Newtonsoft.Json.Converters.StringEnumConverter());
                receiver.Log(json);
            }
        }
Beispiel #4
0
        /// <summary>
        /// The main program
        /// </summary>
        /// <param name="argv">The command line arguments</param>
        public static void Main(string[] argv)
        {
            // Load connection info for Splunk server in .splunkrc file.
            var cli = Command.Splunk("submit");
            cli.Parse(argv);
            var service = Service.Connect(cli.Opts);

            var args = new ReceiverSubmitArgs
            {
                Source = "splunk-sdk-tests",
                SourceType = "splunk-sdk-test-event",
            };

            var receiver = new Receiver(service);

            // Submit to default index
            receiver.Submit(args, "Hello World.");
            receiver.Submit(args, "Goodbye world.");
        }
        public bool SendEvent()
        {
            Receiver splunkReceiver = new Receiver(service);


            var args = new Args();
            args.Add("host", "TodaysHostIs");
            args.Add("source", "dynaTrace");
            args.Add("sourcetype", "Monitoring");

            //splunkReceiver.Submit(args, "CurrentlyWorks");

            //The index needs to exist in the splunk database to work, otherwise a 400 error is thrown
            splunkReceiver.Submit("main", args, "EventType=4 Keywords=Classic, RecordNumber=number");

            Console.WriteLine("Submitted Successfully");

            return true;
        }
Beispiel #6
0
        /// <summary>
        /// Emit a batch of log events, running to completion synchronously.
        /// </summary>
        /// <param name="events">The events to emit.</param>
        protected override void EmitBatch(IEnumerable<LogEvent> events)
        {
            _service.Login(_connectionInfo.Username, _connectionInfo.Password);

            var receiver = new Receiver(_service);

            foreach (var logEvent in events)
            {
                var data = new { logEvent.Timestamp, logEvent.Level, Data = logEvent.RenderMessage() };
                var json = JsonConvert.SerializeObject(data, new StringEnumConverter());
                receiver.Log(_receiveSubmitArgs, json);
            }
        }
        public bool OpenStream(string index = "main", string host = "localhost",
    string source = "dynaTrace", string sourcetype = "dynatrace/xml")
        {
            if (!connected) return false;

            Receiver splunkReceiver = new Receiver(service);

            var args = new Args();

            args.Add("host", host);
            args.Add("source", source);
            args.Add("sourcetype", sourcetype);

            iStream = splunkReceiver.Attach("main", args);

            Console.WriteLine("Opened Input Stream");
            return true;
        }