public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "t=|title=", "A title for the API key", t => _title = ArgumentString.Normalize(t)); Options.Add( "token=", "A pre-allocated API key token; by default, a new token will be generated and written to `STDOUT`", t => _token = ArgumentString.Normalize(t)); _properties = Enable <PropertiesFeature>(); Options.Add( "filter=", "A filter to apply to incoming events", f => _filter = ArgumentString.Normalize(f)); Options.Add( "minimum-level=", "The minimum event level/severity to accept; the default is to accept all events", v => _level = ArgumentString.Normalize(v)); Options.Add( "use-server-timestamps", "Discard client-supplied timestamps and use server clock values", _ => _useServerTimestamps = true); _connection = Enable <ConnectionFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); }
public SeqConnection Connect(ConnectionFeature connection) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } string url, apiKey; if (connection.IsUrlSpecified) { url = connection.Url; apiKey = connection.ApiKey; } else if (connection.IsProfileNameSpecified) { if (!_config.Profiles.TryGetValue(connection.ProfileName, out var profile)) { throw new ArgumentException($"A profile named `{connection.ProfileName}` was not found; see `seqcli profile list` for available profiles."); } url = profile.ServerUrl; apiKey = profile.ApiKey; } else { url = _config.Connection.ServerUrl; apiKey = connection.IsApiKeySpecified ? connection.ApiKey : _config.Connection.ApiKey; } return(new SeqConnection(url, apiKey)); }
public LogCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "m=|message=", "A message to associate with the event (the default is to send no message); https://messagetemplates.org syntax is supported", v => _message = v); Options.Add( "l=|level=", "The level or severity of the event (the default is `Information`)", v => _level = v); Options.Add( "t=|timestamp=", "The event timestamp as ISO-8601 (the current UTC timestamp will be used by default)", v => _timestamp = v); Options.Add( "x=|exception=", "Additional exception or error information to send, if any", v => _exception = v); _properties = Enable <PropertiesFeature>(); _connection = Enable <ConnectionFeature>(); }
protected override async Task <int> Run() { // An API key is not accepted; we don't want to imply that /health requires authentication. var surrogateConnectionFeature = new ConnectionFeature { ProfileName = _profileName, Url = _serverUrl }; var connection = _connectionFactory.Connect(surrogateConnectionFeature); try { var response = await connection.Client.HttpClient.GetAsync("health"); Console.WriteLine($"HTTP {response.Version} {((int)response.StatusCode).ToString(CultureInfo.InvariantCulture)} {response.ReasonPhrase}"); foreach (var(key, values) in response.Headers.Concat(response.Content.Headers)) { foreach (var value in values) { Console.WriteLine($"{key}: {value}"); } } Console.WriteLine(await response.Content.ReadAsStringAsync()); return(response.IsSuccessStatusCode ? 0 : 1); } catch (Exception ex) { Log.Information(ex, "Exception thrown when calling health endpoint"); Console.WriteLine("Unreachable"); Console.WriteLine(Presentation.FormattedMessage(ex)); return(1); } }
public ImportCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory; Options.Add( "i=|input=", "The directory from which to read the set of `.template` files; the default is `.`", i => _inputDir = ArgumentString.Normalize(i)); Options.Add( "state=", "The path of a file which will persist a mapping of template names to the ids of the created " + "entities on the target server, avoiding duplicates when multiple imports are performed; by default, " + "`import.state` in the input directory will be used", s => _stateFile = ArgumentString.Normalize(s)); Options.Add( "merge", "For templates with no entries in the `.state` file, first check for existing entities with matching names or titles; " + "does not support merging of retention policies", _ => _merge = true); _args = Enable(new PropertiesFeature("g", "arg", "Template arguments, e.g. `-g ownerId=user-314159`")); _connection = Enable <ConnectionFeature>(); }
public RenderCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "i=|id=", "The id of a single dashboard to render", t => _id = ArgumentString.Normalize(t)); Options.Add("c=|chart=", "The title of a chart on the dashboard to render", c => _chartTitle = ArgumentString.Normalize(c)); Options.Add("last=", "A duration over which the chart should be rendered, e.g. `7d`; this will be aligned to an interval boundary; either `--last` or `--start` and `--end` must be specified", v => _lastDuration = ArgumentString.Normalize(v)); Options.Add("by=", "The time-slice interval for the chart data, as a duration, e.g. `1h`", v => _intervalDuration = ArgumentString.Normalize(v)); _range = Enable <DateRangeFeature>(); _signal = Enable <SignalExpressionFeature>(); _timeout = Enable <TimeoutFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); _connection = Enable <ConnectionFeature>(); }
public IngestCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory; _fileInputFeature = Enable(new FileInputFeature("File(s) to ingest", supportsWildcard: true)); _invalidDataHandlingFeature = Enable <InvalidDataHandlingFeature>(); _properties = Enable <PropertiesFeature>(); Options.Add("x=|extract=", "An extraction pattern to apply to plain-text logs (ignored when `--json` is specified)", v => _pattern = string.IsNullOrWhiteSpace(v) ? DefaultPattern : v.Trim()); Options.Add("json", "Read the events as JSON (the default assumes plain text)", v => _json = true); Options.Add("f=|filter=", "Filter expression to select a subset of events", v => _filter = string.IsNullOrWhiteSpace(v) ? null : v.Trim()); Options.Add( "m=|message=", "A message to associate with the ingested events; https://messagetemplates.org syntax is supported", v => _message = string.IsNullOrWhiteSpace(v) ? null : v.Trim()); Options.Add("l=|level=", "The level or severity to associate with the ingested events; this will override any " + "level information present in the events themselves", v => _level = string.IsNullOrWhiteSpace(v) ? null : v.Trim()); _sendFailureHandlingFeature = Enable <SendFailureHandlingFeature>(); _connection = Enable <ConnectionFeature>(); _batchSize = Enable <BatchSizeFeature>(); }
public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "n=|name=", "A unique name for the feed", n => _name = ArgumentString.Normalize(n)); Options.Add( "l=|location=", "The feed location; this may be a NuGet v2 or v3 feed URL, or a local filesystem path on the Seq server", l => _location = ArgumentString.Normalize(l)); Options.Add( "u=|username="******"The username Seq should supply when connecting to the feed, if authentication is required", n => _username = ArgumentString.Normalize(n)); Options.Add( "p=|password="******"A feed password, if authentication is required; note that `--password-stdin` is more secure", p => _password = ArgumentString.Normalize(p)); Options.Add( "password-stdin", "Read the feed password from `STDIN`", _ => _passwordStdin = true); _connection = Enable <ConnectionFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); }
public RemoveCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); _entityIdentity = Enable(new EntityIdentityFeature("API key", "remove")); _connection = Enable <ConnectionFeature>(); }
public bool TryGetApiKey(ConnectionFeature connection, out string apiKey) { apiKey = connection.IsUrlSpecified ? connection.ApiKey : connection.IsApiKeySpecified ? connection.ApiKey : _config.Connection.ApiKey; return(apiKey != null); }
public DemoteCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add("wait", "Wait for the leader to be demoted before exiting", _ => _wait = true); _confirm = Enable <ConfirmFeature>(); _connection = Enable <ConnectionFeature>(); }
public IngestCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); _confirm = Enable <ConfirmFeature>(); _connection = Enable <ConnectionFeature>(); Options.Add("quiet", "Don't echo ingested events to `STDOUT`", _ => _quiet = true); _batchSize = Enable <BatchSizeFeature>(); }
public SetupCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); // The command will also at some point accept an `--allow-outbound-requests` flag, which will cause sample // apps to be installed, and a health check to be set up. _confirm = Enable <ConfirmFeature>(); _connection = Enable <ConnectionFeature>(); }
public ImportCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); _fileInputFeature = Enable(new FileInputFeature("File to import")); _connection = Enable <ConnectionFeature>(); }
public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); _output = Enable(new OutputFormatFeature(config.Output)); _connection = Enable <ConnectionFeature>(); }
public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "t=|title=", "A title for the API key", t => _title = ArgumentString.Normalize(t)); Options.Add( "token=", "A pre-allocated API key token; by default, a new token will be generated and written to `STDOUT`", t => _token = ArgumentString.Normalize(t)); _properties = Enable <PropertiesFeature>(); Options.Add( "filter=", "A filter to apply to incoming events", f => _filter = ArgumentString.Normalize(f)); Options.Add( "minimum-level=", "The minimum event level/severity to accept; the default is to accept all events", v => _level = ArgumentString.Normalize(v)); Options.Add( "use-server-timestamps", "Discard client-supplied timestamps and use server clock values", _ => _useServerTimestamps = true); Options.Add( "permissions=", "A comma-separated list of permissions to delegate to the API key; valid permissions are `Ingest` (default), `Read`, `Write`, `Project` and `System`", v => _permissions = ArgumentString.NormalizeList(v)); Options.Add( "connect-username="******"A username to connect with, useful primarily when setting up the first API key", v => _connectUsername = ArgumentString.Normalize(v)); Options.Add( "connect-password="******"When `connect-username` is specified, a corresponding password", v => _connectPassword = ArgumentString.Normalize(v)); Options.Add( "connect-password-stdin", "When `connect-username` is specified, read the corresponding password from `STDIN`", _ => _connectPasswordStdin = true); _connection = Enable <ConnectionFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); }
public RemoveCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "i=|id=", "The id of a single retention policy to remove", id => _id = id); _connection = Enable <ConnectionFeature>(); }
public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); _entityIdentity = Enable(new EntityIdentityFeature("workspace", "list")); _entityOwner = Enable(new EntityOwnerFeature("workspace", "list", _entityIdentity)); _output = Enable(new OutputFormatFeature(config.Output)); _connection = Enable <ConnectionFeature>(); }
public TailCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "f=|filter=", "An optional server-side filter to apply to the stream, for example `@Level = 'Error'`", v => _filter = v); _output = Enable(new OutputFormatFeature(config.Output)); _signal = Enable <SignalExpressionFeature>(); _connection = Enable <ConnectionFeature>(); }
public IngestCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory; _fileInputFeature = Enable <FileInputFeature>(); _invalidDataHandlingFeature = Enable <InvalidDataHandlingFeature>(); _properties = Enable <PropertiesFeature>(); Options.Add("f=|filter=", "Filter expression to select a subset of events", v => _filter = string.IsNullOrWhiteSpace(v) ? null : v.Trim()); _connection = Enable <ConnectionFeature>(); }
public RemoveCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory; _connection = Enable <ConnectionFeature>(); Options.Add( "t=|title=", "Remove API Keys with the specified title", (t) => _title = t); Options.Add( "i=|id=", "Remove API Keys with the specified Id", (t) => _id = t); }
public QueryCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add("q=|query=", "The query to execute", v => _query = v); _range = Enable <DateRangeFeature>(); _signal = Enable <SignalExpressionFeature>(); Options.Add("timeout=", "The query execution timeout in milliseconds", v => _timeoutMS = int.Parse(v?.Trim() ?? "0")); _output = Enable(new OutputFormatFeature(config.Output)); _connection = Enable <ConnectionFeature>(); }
public ListCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "i=|id=", "The id of a single retention policy to list", id => _id = id); _output = Enable(new OutputFormatFeature(config.Output)); _connection = Enable <ConnectionFeature>(); }
public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "n=|name=", "A unique username for the user", u => _username = ArgumentString.Normalize(u)); Options.Add( "d=|display-name=", "A long-form name to aid in identifying the user", d => _displayName = ArgumentString.Normalize(d)); Options.Add( "f=|filter=", "A view filter that limits the events visible to the user", f => _filter = ArgumentString.Normalize(f)); Options.Add( "r=|role=", "The title of a role that grants the user permissions on the server; if not specified, the default new user role will be assigned", r => _roleTitle = ArgumentString.Normalize(r)); Options.Add( "e=|email=", "The user's email address (enables a Gravatar image for the user)", e => _emailAddress = ArgumentString.Normalize(e)); Options.Add( "p=|password="******"An initial password for the user, if username/password authentication is in use; note that `--password-stdin` is more secure", p => _password = ArgumentString.Normalize(p)); Options.Add( "password-stdin", "Read the initial password for the user from `STDIN`, if username/password authentication is in use", _ => _passwordStdin = true); Options.Add( "no-password-change", "Don't force the user to change their password at next login", _ => _noPasswordChange = true); _connection = Enable <ConnectionFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); }
bool _deleteAllEvents; // Currently the only supported option public CreateCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "after=", "A duration after which the policy will delete events, e.g. `7d`", v => _afterDuration = ArgumentString.Normalize(v)); Options.Add( "delete-all-events", "The policy should delete all events (currently the only supported option)", _ => _deleteAllEvents = true); _connection = Enable <ConnectionFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); }
public ListCommand(SeqConnectionFactory connectionFactory, SeqCliOutputConfig outputConfig) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "n=|name=", "The name of the cluster node to list", n => _name = n); Options.Add( "i=|id=", "The id of a single cluster node to list", id => _id = id); _output = Enable(new OutputFormatFeature(outputConfig)); _connection = Enable <ConnectionFeature>(); }
public ImportCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "merge", "Update signals that have ids matching those in the imported data; the default is to always create new signals", _ => _merge = true); _fileInputFeature = Enable(new FileInputFeature("File to import")); _entityOwner = Enable(new EntityOwnerFeature("signal", "import")); _connection = Enable <ConnectionFeature>(); }
public SearchCommand(SeqConnectionFactory connectionFactory, SeqCliConfig config) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add( "f=|filter=", "A filter to apply to the search, for example `Host = 'xmpweb-01.example.com'`", v => _filter = v); Options.Add( "c=|count=", $"The maximum number of events to retrieve; the default is {_count}", v => _count = int.Parse(v, CultureInfo.InvariantCulture)); _range = Enable <DateRangeFeature>(); _output = Enable(new OutputFormatFeature(config.Output)); _signal = Enable <SignalExpressionFeature>(); _connection = Enable <ConnectionFeature>(); }
public ApplyCommand(SeqConnectionFactory connectionFactory) { _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); Options.Add("c=|certificate=", "Certificate file; the file must be UTF-8 text", v => _certificateFilename = ArgumentString.Normalize(v)); Options.Add("certificate-stdin", "Read the license certificate from `STDIN`", _ => _certificateStdin = true); Options.Add("automatically-refresh", "If the license is for a subscription, periodically check `datalust.co` and automatically refresh " + "the certificate when the subscription is changed or renewed", _ => _automaticallyRefresh = true); _connection = Enable <ConnectionFeature>(); }
public SocketConnection(Socket socket, ServiceContext context) { _socket = socket; ServiceContext = context; _trace = ServiceContext.Log; var localEndPoint = (IPEndPoint)_socket.LocalEndPoint; var remoteEndPoint = (IPEndPoint)_socket.RemoteEndPoint; ConnectionFeature = new ConnectionFeature { ConnectionId = CorrelationIdGenerator.GetNextId(), LocalEndPoint = localEndPoint, RemoteEndPoint = remoteEndPoint, }; _receiver = new SocketReceiver(_socket); _sender = new SocketSender(_socket); }