BothDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Miguel-Rodriguez15/msvc/llms.txt
Use this file to discover all available pages before exploring further.
msvc-usuarios and msvc-cursos emit structured JSON logs via Logback and ship them over TCP to Logstash on port 5000. Logstash normalizes the events and writes them to Elasticsearch under dynamic per-service, per-date indices. Kibana provides a browser UI for searching, filtering, and visualizing the aggregated log stream.
Services and Ports
| Service | URL | Purpose |
|---|---|---|
| Elasticsearch | http://localhost:9200 | Stores and indexes log documents |
| Kibana | http://localhost:5601 | Search and visualize logs |
| Logstash TCP input | localhost:5000 | Receives JSON log events from services |
Starting the ELK Stack
All three components are defined indocker-compose-elk.yml and run on a shared elk bridge network. Start them with:
Logstash Pipeline
The pipeline file atlogstash/pipeline/logstash.conf is mounted into the Logstash container and controls how log events are received, transformed, and routed to Elasticsearch.
- Input — Listens on TCP port 5000 using the
json_linescodec. Each newline-delimited JSON object sent by a service becomes one Elasticsearch document. - Filter — Reads the
service_namefield that each microservice injects into every log event. If present, it is lowercased and stored in[@metadata][index_name]for use in the output stage. Events lacking aservice_namefield are routed to anunknown-serviceindex so they are never silently dropped. - Output — Writes to Elasticsearch using a dynamic index name composed of the service name and the current UTC date (
YYYY.MM.dd). A secondarystdoutoutput withrubydebugcodec echoes events to the Logstash container log, which is useful for debugging the pipeline.
Logback Configuration
Each microservice activates the ELK Logback profile by running with the Spring profileelk. When that profile is active, Logback uses LogstashTcpSocketAppender to open a persistent TCP connection to Logstash and stream JSON-encoded log events in real time.
Both services share an identical Logback configuration pattern. The snippet below is from msvc-usuarios/src/main/resources/logback-spring.xml (the msvc-cursos configuration is identical, differing only in its default APP_NAME):
LogstashEncoderserializes every log event as a single-line JSON object, compatible with thejson_linescodec configured in Logstash.customFieldsinjects"service_name"into every event using the value ofspring.application.name(msvc-usuariosormsvc-cursos). The Logstash filter uses this field to build the dynamic index name.includeMdcKeyName traceIdforwards distributed trace IDs if they are present in the MDC, enabling cross-service log correlation.- The destination falls back to
localhost:5000when theLOGSTASH_HOSTenvironment variable is not set, so the configuration works both locally and in Docker/Kubernetes (whereLOGSTASH_HOSTis set to the Logstash service name).
elk Spring profile:
Index Pattern
Elasticsearch indices follow the naming convention:Kibana Setup
Open Kibana
Navigate to http://localhost:5601 in your browser. Allow up to 60 seconds for Kibana to finish initializing on first startup.
Go to Index Patterns / Data Views
Open the main menu and navigate to Stack Management → Index Patterns (Kibana 7) or Stack Management → Data Views (Kibana 8).
Create the index pattern
Click Create index pattern (or Create data view) and enter the pattern:This wildcard matches all service indices regardless of service name or date.
Set the time field
When prompted for a time field, select
@timestamp. This is the field automatically populated by LogstashEncoder and enables time-range filtering in Discover.Searching Logs
Kibana’s Discover view accepts KQL (Kibana Query Language) expressions in the search bar. Common queries for this project:| Goal | KQL query |
|---|---|
| Logs from msvc-usuarios only | service_name: msvc-usuarios |
| Logs from msvc-cursos only | service_name: msvc-cursos |
| Error-level events across all services | level: ERROR |
| Warnings from msvc-cursos | service_name: msvc-cursos AND level: WARN |
| All events in the last hour | Use the time picker — select Last 1 hour |
| Events containing a specific message | message: *NullPointer* |
+ filter automatically.
ELK Versions
All three images indocker-compose-elk.yml are pinned to ELK Stack 8.11.0:
xpack.security.enabled=false) for local development simplicity. Do not use this configuration in production without re-enabling X-Pack security.
The ELK stack is resource-intensive. Elasticsearch alone recommends at least 2 GB of JVM heap in production. The
docker-compose-elk.yml in this project configures Elasticsearch with 512 MB (-Xms512m -Xmx512m) and Logstash with 256 MB (-Xms256m -Xmx256m) to keep local resource usage manageable. Ensure Docker Desktop has at least 8 GB of memory allocated for the full ELK stack alongside the microservices.