seq

Seq is an intelligent platform for indexing modern structured logs, searching, analyzing, and building alerts notifying potential incidents. You can use it in the local development environment and/or in a production environment.

In our scenario, we use a local instance of Seq run by docker as described in the documentation and two microservices (ms-order/ms-payment).

Follow the steps:

  1. Install the Devprime CLI.

  2. Initialize the Seq container provided in the docker documentation.

  3. Clone the repository with the two microservices (ms-order/ms-payment) or deploy manually.
    git clone https://github.com/devprime/devprime-microservices-order-payment.git

  4. Update the Stack by running on the main folder to detect both microservices
    dp stack

  5. Locate the configuration file in the folder of each microservice “appsettings.json” and edit as instructed below.

a) Open the configuration file in each microservice folder (ms-order/ms-payment) as per the command below or directly from Visual Studio Code.
code src/App/appsettings.json

b) Locate the Observability key and verify that the Enable option is true in the main key and the Log option. Locate the ShowAppName and HideDateTime key and set it to true to show the name of the microservice and set the date and time since Seq will automatically include it.

c) Locate the Export option and set the Enable to true, Type to seq and the Endpoint with the url of the service that in the local docker url has the default value of “http://localhost:5431”. In this scenario, we won’t tell you the value of the Apikey, which is a Seq protection key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"Devprime_Observability": {
    "Enable": "true",
    "Log": {
      "Enable": "true",
      "Save": "false",
      "Type": "text",
      "FileSize": "5242880",
      "HideDetails": "false",
      "HideDateTime": "true",
      "ShowAppName": "true",
      "Path": "",
      "ShowHttpErrors": "400",
      "Export": {
        "Enable": "true",
        "Type": "seq",
        "Host": "http://localhost:5341",
        "ApiKey": "your api key",
        "ControlLevelSwitch": "Information"
      }
    },
    "Metrics": {
      "Enable": "false"
    },
    "Trace": {
      "Enable": "false",
      "Type": "zipkin",
      "Endpoint": "http://localhost:9411/api/v2/spans"
    }
  },

To make it easier to view the logs in the Seq tool, we will hide the timestamp of the logs and enable the display of the names of each microservice.

Tracking distributed logging across two or more microservices

  1. Run both microservices (ms-order/ms-payment) at the same time
  2. Open ms-order in the browser under http://localhost:5000 and make one or more posts in /v1/order
  3. Open Seq in the browser under http://localhost:8000 and view the logs

Distributed Logs using Seq and Devprime

  1. Viewing the Detail of a Particular Log

Distributed Logs using Seq and Devprime

  1. Filtering Logs Related to a Trace ID

Searching Distributed Logs using Seq and Devprime

Legal information:
Seq is a product of [Datalust and licensing must be contracted directly with the manufacturer.

Last modified April 11, 2024 (cc33f7e6)