Ejemplo n.º 1
0
        /// <summary>
        /// Create an instance of the SplunkViaHttp sink.
        /// </summary>
        /// <param name="context">Connection info.</param>
        /// <param name="index">The name of the splunk index to log to</param>
        /// <param name="userName">The username to authenticate with</param>
        /// <param name="password">The password to authenticate with</param>
        /// <param name="batchSizeLimit">The size of the batch prior to logging</param>
        /// <param name="batchInterval">The interval on which to log via http</param>
        /// <param name="resourceNamespace">The resource namespaces</param>
        /// <param name="transmitterArgs">The </param>
        /// <param name="formatProvider">The format provider to be used when rendering the message</param>
        public SplunkViaHttpSink(
            SplunkClient.Context context,
            string index,
            string userName,
            string password,
            int batchSizeLimit,
            TimeSpan batchInterval,
            SplunkClient.Namespace resourceNamespace     = null,
            SplunkClient.TransmitterArgs transmitterArgs = null,
            IFormatProvider formatProvider = null
            )
        {
            _index           = index;
            _userName        = userName;
            _password        = password;
            _batchSizeLimit  = batchSizeLimit;
            _transmitterArgs = transmitterArgs;

            _queue = new ConcurrentQueue <LogEvent>();

            _jsonFormatter = new JsonFormatter(renderMessage: true, formatProvider: formatProvider);

            _service = resourceNamespace == null
                ? new SplunkClient.Service(context, new SplunkClient.Namespace("nobody", "search"))
                : new SplunkClient.Service(context, resourceNamespace);


            RepeatAction.OnInterval(batchInterval, () => ProcessQueue().Wait(), new CancellationToken());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates an instance of the SplunkViaHttp context
 /// </summary>
 public SplunkContext(SplunkClient.Context context,
                      string index,
                      string username,
                      string password,
                      SplunkClient.Namespace resourceNamespace     = null,
                      SplunkClient.TransmitterArgs transmitterArgs = null)
     : base(context.Scheme, context.Host, context.Port)
 {
     Index             = index;
     Username          = username;
     Password          = password;
     ResourceNamespace = resourceNamespace;
     TransmitterArgs   = transmitterArgs;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerMessage"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="name">
 /// The name of the <see cref="ServerMessage"/>.
 /// </param>
 ///
 /// ### <exception cref="ArgumentException">
 /// <paramref name="name"/> is <c>null</c> or empty.
 /// </exception>
 /// ### <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// ### <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 protected internal ServerMessage(Context context, Namespace ns, string name)
     : base(context, ns, ServerMessageCollection.ClassResourceName, name)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityCollection<TCollection, TEntity>"/> class.
 /// </summary>
 /// <param name="context">
 /// </param>
 /// <param name="namespace">
 /// </param>
 /// <param name="resource">
 /// </param>
 /// <param name="args">
 /// </param>
 internal EntityCollection(Context context, Namespace @namespace, ResourceName resource, IEnumerable <Argument>
                           args = null)
     : base(context, @namespace, resource)
 {
     this.args = args;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Intializes a new instance of the <see cref="ServerMessageCollection"/>
 /// class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 protected internal ServerMessageCollection(Context context, Namespace ns)
     : base(context, ns, ClassResourceName)
 {
 }
Ejemplo n.º 6
0
 public ServerInfo(Context context, Namespace @namespace)
     : base(context, @namespace, ClassResourceName)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Service"/> class.
 /// </summary>
 /// <param name="scheme">
 /// The scheme for the new <see cref="Service"/>.
 /// </param>
 /// <param name="host">
 /// The host for the new <see cref="Service"/>.
 /// </param>
 /// <param name="port">
 /// The port for the new <see cref="Service"/>.
 /// </param>
 /// <param name="ns">
 /// The namespace for requests issue by the new <see cref="Service"/>.
 /// </param>
 ///
 /// ### <exception name="ArgumentException">
 /// <paramref name="scheme"/> is invalid, <paramref name="host"/> is
 /// <c>null</c> or empty, or <paramref name="port"/> is less than zero
 /// or greater than <c>65535</c>.
 /// </exception>
 public Service(Scheme scheme, string host, int port, Namespace ns = null)
     : this(new Context(scheme, host, port), ns)
 {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Index"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="name">
 /// Name of the index to be represented by the current instance.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/>, <paramref name="ns"/>, or <paramref
 /// name="name"/> are <c>null</c>.
 /// </exception>
 internal Index(Context context, Namespace ns, string name)
     : base(context, ns, ClassResourceName, name)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="JobCollection"/>
 /// class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 protected internal JobCollection(Context context, Namespace ns)
     : base(context, ns, ClassResourceName)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Server"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="namespace">
 /// An object identifying a Splunk service namespace.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <see cref="context"/> or <see cref="namespace"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <see cref="namespace"/> is not specific.
 /// </exception>
 internal Server(Context context, Namespace @namespace)
     : base(context, @namespace, ClassResourceName)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StoragePassword"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="namespace">
 /// An object identifying a Splunk service namespace.
 /// </param>
 /// <param name="username">
 /// Username associated with the <see cref="StoragePassword"/>.
 /// </param>
 /// <param name="username">
 /// Realm associated with the <see cref="StoragePassword"/>.
 /// </param>
 /// <exception cref="ArgumentException">
 /// <see cref="name"/> is <c>null</c> or empty.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <see cref="context"/> or <see cref="namespace"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <see cref="namespace"/> is not specific.
 /// </exception>
 internal StoragePassword(Context context, Namespace @namespace, string username, string realm = "")
     : base(context, @namespace, StoragePasswordCollection.ClassResourceName, CreateNameFromRealmAndUsername(
                realm ?? "", username))
 {
     Contract.Requires <ArgumentNullException>(username != null);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StoragePassword"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="username">
 /// Username associated with the <see cref="StoragePassword"/>.
 /// </param>
 /// <param name="realm">
 /// Realm associated with the <see cref="StoragePassword"/> or <c>
 /// null</c>. The default value is <c>null</c>.
 /// </param>
 /// <exception cref="ArgumentException">
 /// <paramref name="username"/> is <c>null</c> or empty.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 internal StoragePassword(Context context, Namespace ns, string username, string realm = null)
     : base(context, ns, CreateResourceNameFromRealmAndUsername(realm ?? "", username))
 {
     Contract.Requires <ArgumentNullException>(username != null);
 }
Ejemplo n.º 13
0
 internal ConfigurationSetting(Context context, Namespace @namespace, string fileName, string stanzaName,
                               string keyName)
     : base(context, @namespace, new ResourceName(ConfigurationCollection.ClassResourceName, fileName, stanzaName), keyName)
 {
 }
Ejemplo n.º 14
0
 internal ApplicationSetupInfo(Context context, Namespace @namespace, string name)
     : base(context, @namespace, new ResourceName(ApplicationCollection.ClassResourceName, name, "setup"))
 {
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Application"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="namespace">
 /// An object identifying a Splunk service namespace.
 /// </param>
 /// <param name="name">
 /// The name of this application.
 /// </param>
 /// <exception cref="ArgumentException">
 /// <see cref="name"/> is <c>null</c> or empty.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <see cref="context"/> or <see cref="namespace"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <see cref="namespace"/> is not specific.
 /// </exception>
 internal Application(Context context, Namespace @namespace, string name)
     : base(context, @namespace, ApplicationCollection.ClassResourceName, name)
 {
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Application"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="name">
 /// The name of the <see cref="Application"/>.
 /// </param>
 protected internal Application(Context context, Namespace ns, string name)
     : base(context, ns, ApplicationCollection.ClassResourceName, name)
 {
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Job"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="name">
 /// Name of the search <see cref="Job"/>.
 /// </param>
 /// <exception cref="ArgumentException">
 /// <paramref name="name"/> is <c>null</c> or empty.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 internal Job(Context context, Namespace ns, string name)
     : base(context, ns, JobCollection.ClassResourceName, name)
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Service"/> class.
 /// </summary>
 /// <param name="uri">
 /// Uri for the service <see cref="Service"/>.
 /// </param>
 /// <param name="ns">
 /// The namespace for requests issue by the new <see cref="Service"/>.
 /// </param>
 /// <exception name="ArgumentNullException">
 /// <paramref name="uri"/> is null.
 /// </exception>
 /// <exception name="ArgumentException">
 /// The <paramref name="uri"/> scheme is not http or https or the <paramref name="uri"/> port number is less than
 /// zero or greater than 65,535.
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// The <paramref name="uri"/> represents a relative URI, and this constructor can only be used with absolute URIs.
 /// </exception>
 public Service(Uri uri, Namespace ns = null)
     : this(new Context(GetScheme(uri.Scheme), uri.Host, uri.Port), ns)
 {
     Contract.Requires <ArgumentNullException>(uri != null);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Endpoint"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="name">
 /// An object identifying a Splunk resource within <paramref name="ns"/>.
 /// </param>
 ///
 /// ### <exception cref="ArgumentNullException">
 /// <paramref name="context"/>, <paramref name="ns"/>, or
 /// <paramref name= "name"/> are <c>null</c>.
 /// </exception>
 /// ### <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 public Endpoint(Context context, Namespace ns, ResourceName name)
 {
     this.Initialize(context, ns, name);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Server"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/> or <paramref name="ns"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 internal Server(Context context, Namespace ns)
     : base(context, ns, ClassResourceName)
 {
     this.messages = new ServerMessageCollection(context, ns);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseEntity&lt;TResource&gt;"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="collection">
 /// The <see cref="ResourceName"/> of an <see cref="EntityCollection&lt;TEntity,TResource&gt;"/>.
 /// </param>
 /// <param name="name">
 /// An object identifying a Splunk resource within the resource identfied by <paramref name="collection"/>.
 /// </param>
 protected BaseEntity(Context context, Namespace ns, ResourceName collection, string name)
     : base(context, ns, new ResourceName(collection, name))
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseEntity&lt;TResource&gt;"/>
 /// class as specified by <paramref name="context"/>, <paramref name="ns"/>
 /// and "<paramref name="resourceName"/>.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="resourceName">
 /// An object identifying a Splunk resource within <paramref name="ns"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/>, <paramref name="ns"/>, or
 /// <paramref name= "resourceName"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 protected BaseEntity(Context context, Namespace ns, ResourceName resourceName)
     : base(context, ns, resourceName)
 {
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Entity&lt;TResource&gt;"/> class.
 /// </summary>
 /// <param name="context">
 /// An object representing a Splunk server session.
 /// </param>
 /// <param name="ns">
 /// An object identifying a Splunk services namespace.
 /// </param>
 /// <param name="collection">
 /// The <see cref="ResourceName"/> of an <see cref="EntityCollection&lt;TEntity,TResource&gt;"/>.
 /// </param>
 /// <param name="name">
 /// The name of an entity within <paramref name="collection"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="context"/>, <paramref name="ns"/>, or <paramref
 /// name="collection"/>, or <paramref name="name"/> are <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// <paramref name="ns"/> is not specific.
 /// </exception>
 protected internal Entity(Context context, Namespace ns, ResourceName collection, string name)
     : this(context, ns, new ResourceName(collection, name))
 {
 }