Seq Documentation and Support

Seq Documentation and Support

Welcome to the Seq documentation hub. You'll find comprehensive guides and documentation to help you start working with Seq as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    
Ask A Question

Questions

3

Considerations when using SEQ as AuditLog

We have been considering the Pros and Cons of using SEQ as the repository for our AuditLog. I have read a few questions in this forum (eg. [This] (https://docs.getseq.net/discuss/5818946bb1e11c1900bf76b2) and [This](https://docs.getseq.net/discuss/58401d08de0ace190064cec5) ). However I still have a few questions: **What's the difference between WriteTo and AuditTo?** Assuming that the SEQ server and the connection to the SEQ server doesn't go down - I would guess that WriteTo still maintains the same sequence of events as AuditTo? Or that this problem could be solved using a timestamp generated in the client code? As far as I have understood this - just using WriteTo and not generating the 'auditing timestamp' - but relying on the SEQ server timestamp will actually be a problem for the sequence? **Is there a difference with exceptions, when using WriteTo and AuditTo?** In one of the previous post - answers you wrote: > AuditTo has the advantage of logging synchronously and propagating any exceptions, > but of course comes with a corresponding performance cost. You could use a second > server and WriteTo if guaranteed audit logging isn't a strict requirement. Could you try and explain this in a bit more detail? **Is performance good enough?** When sending both regular 'warnings and errors' to SEQ the number should be pretty low, but including an audit trail for each user severily increases the number of events sent to SEQ. Do you have a kind of 'formula' to use when trying to estimate disc usage and other HW specs? The reason I'm asking is that it could be a requirement to keep this kind of data between 1-5 years and I'm kind of worried that disc space especially could be an issue - because the auditlog cannot be deleted and it should also still be searchable. **Could you perhaps add a seperate documentation section about using SEQ as AuditLog?** SEQ has many advantages and I'm assuming that we are not the first ones considering to use SEQ as a audit log repo - it might be worth it to keep a seperate link on the documentation page about this. Just describing those 'special concerns' that needs to be thought about when using SEQ for this fairly important log.

Posted by Allan 11 months ago

1

Using Seq for Python with Flask

I have the code below to configure the project to log to seq. Which was copy and pasted from the documentation. ''' import json import logging from flask import Flask from config import Config import seqlog app = Flask(__name__) app.config.from_object(Config) seqlog.log_to_seq( server_url="http://***:5341/", api_key="***", level=logging.DEBUG, batch_size=5, auto_flush_timeout=2, # seconds override_root_logger=True, json_encoder_class=json.encoder.JSONEncoder ) import views ''' When the app starts i get the following error: ''' FLASK_APP = app.py FLASK_ENV = development FLASK_DEBUG = 0 In folder /Users/kelvinmacartney/PycharmProjects/comp-2011-cwk-2 /Users/kelvinmacartney/PycharmProjects/comp-2011-cwk-2/venv/bin/python -m flask run * Serving Flask app "app.py" * Environment: development * Debug mode: off /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/ext/declarative/base.py:325: SAWarning: Attribute 'username' on class <class 'models.User'> appears to be a non-schema 'sqlalchemy.sql.column()' object; this won't be part of the declarative mapping (key, cls)) /usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/ext/declarative/base.py:325: SAWarning: Attribute 'email' on class <class 'models.User'> appears to be a non-schema 'sqlalchemy.sql.column()' object; this won't be part of the declarative mapping (key, cls)) Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 1158, in run self.function(*self.args, **self.kwargs) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seqlog/consumer.py", line 67, in flush self.callback(current_batch) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/seqlog/structured_logging.py", line 366, in publish_log_batch request_body_json = json.dumps(request_body, cls=self.json_encoder_class) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 238, in dumps **kw).encode(obj) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type ColumnSet is not JSON serializable ''' The site runs fine, but when i try to log i get an exception. Is there something i'm missing?

Posted by Kelvin Macartney 11 months ago

4

NullReferenceException in response when Seqlog posts to the raw events end-point

Hi. I'm the maintainer of the [Seqlog](https://github.com/tintoy/seqlog) library for Python. I only have a license for Seq 4.x so I haven't tried this myself, but [from what users tell me](https://github.com/tintoy/seqlog/issues/17), it seems that something has changed in Seq 5.x and when they attempt to use it with the latest version they see the following error (with an HTTP 500 from Seq): ```json { "@t": "2018-11-18T06:10:09.6170577Z", "@mt": "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms", "@r": ["0.6036"], "@l": "Error", "@x": "System.NullReferenceException: Object reference not set to an instance of an object.\n at Seq.Server.Web.Api.RawEventsController.TryParseBody(ApiKey apiKey, StorageEventCreationData[]& events, String& errorMessage)\n at Seq.Server.Web.Api.RawEventsController.Ingest()\n at lambda_method(Closure , Object , Object[] )\n at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()\n at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)\n at Seq.Server.Web.Middleware.WebSocketAcceptMiddleware.Invoke(HttpContext context)\n at Seq.Server.Web.Middleware.RequestAuthenticationMiddleware.Invoke(HttpContext httpContext)\n at Seq.Server.Web.Middleware.BrowserSecurityOptionsMiddleware.Invoke(HttpContext context)\n at Seq.Server.Web.Middleware.RequestCompletionMiddleware.Invoke(HttpContext httpContext)", "RequestMethod": "POST", "RequestPath": "/api/events/raw", "StatusCode": 500, "Elapsed": 0.6036, "ErrorToken": "b2c14ff04fbc42348e951aec12f7f637", "RequestProtocol": "HTTP/1.1", "RequestHost": "localhost:5341", "RequestHeaders": { "User-Agent": "python-requests/2.18.4", "Content-Length": "1103" }, "SourceContext": "Seq.Server.Web.Middleware.RequestCompletionMiddleware", "RequestId": "0HLIC0HN27AR5:00000001", "CorrelationId": null, "ConnectionId": "0HLIC0HN27AR5" } ``` The request body is: ```json { "Events": [ { "Timestamp": "2018-11-17 09:05:47.256725+02:00", "Level": "INFO", "MessageTemplate": "Hi, {name}. {greeting}", "Properties": { "MachineName": "IL-GZigelman", "ProcessId": 17860, "LoggerName": "root", "name": "Root logger", "greeting": "Nice to meet you", "ThreadId": 20616, "ThreadName": "MainThread" } }, { "Timestamp": "2018-11-17 09:05:47.256725+02:00", "Level": "INFO", "MessageTemplate": "Hi, {name}! {greeting}", "Properties": { "MachineName": "IL-GZigelman", "ProcessId": 17860, "LoggerName": "A", "name": "world", "greeting": "Nice to meet you", "ThreadId": 20616, "ThreadName": "MainThread" } }, { "Timestamp": "2018-11-17 09:05:47.256725+02:00", "Level": "INFO", "MessageTemplate": "Bye, {name}! {greeting}", "Properties": { "MachineName": "IL-GZigelman", "ProcessId": 17860, "LoggerName": "A.B", "name": "moon", "greeting": "Nice to meet you", "ThreadId": 20616, "ThreadName": "MainThread" } }, { "Timestamp": "2018-11-17 09:05:47.256725+02:00", "Level": "INFO", "MessageTemplate": "By, moon!", "Properties": { "MachineName": "IL-GZigelman", "ProcessId": 17860, "LoggerName": "C", "0": "moon" } } ] } ```

Posted by Adam Friedman about a year ago