{"id":1506,"date":"2025-03-13T18:16:49","date_gmt":"2025-03-13T16:16:49","guid":{"rendered":"https:\/\/www.rocworks.at\/wordpress\/?p=1506"},"modified":"2025-03-13T18:20:16","modified_gmt":"2025-03-13T16:20:16","slug":"capturing-wincc-unified-traces-and-logs-to-elasticsearch","status":"publish","type":"post","link":"https:\/\/www.rocworks.at\/wordpress\/?p=1506","title":{"rendered":"Capturing WinCC Unified Traces to Elasticsearch"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In industrial automation, logging and monitoring are crucial for maintaining system health and troubleshooting issues. Siemens WinCC Unified provides built-in tracing capabilities that. In this post I will show how to capture that traces to Elasticsearch to allow seamless log collection, storage, and visualization. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Capturing WinCC Unified Traces<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WinCC Unified provides a trace tool that simplifies the process of collecting traces. The tool allows logs to be written to files, which can then be read by Logstash (a tool to process log files).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In that example we will write the log files to C:\\Tools\\logstash-siemens\\logs directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>\"C:\\Program Files\\Siemens\\Automation\\WinCCUnified\\bin\\RTILtraceTool.exe\" -mode logger -path C:\\Tools\\logstash-siemens\\logs\n<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Collecting Logs with Logstash<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create a Logstash configuration file (e.g.,\u00a0<code><code>C:\\Tools\\logstash-siemens\\logstash.conf<\/code><\/code>) with the following setup:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>input {\n  file {\n    path => \"C:\/Tools\/logstash-siemens\/logs\/*.log\"  # Use forward slashes for Windows paths\n    start_position => \"beginning\"\n    sincedb_path => \"C:\/Tools\/logstash-siemens\/sincedb\"  # Save the reading state\n    codec => plain {\n      charset => \"UTF-8\"\n    }\n  }\n}\n\nfilter {\n  # Drop empty lines\n  if &#91;message] =~ \/^\\s*$\/ {\n    drop { }\n  }\n\n  # Add a custom field to identify the log source\n  mutate {\n    add_field => { \"Source\" => \"WinCC Unified\" }\n  }\n\n  # Use dissect to parse the log format correctly\n  dissect {\n    mapping => {\n      \"message\" => \"%{#}|%{Host}|%{System}|%{Application}|%{Subsystem}|%{Module}|%{Severity}|%{Flags}|%{Timestamp}|%{Process\/Thread}|%{Message}\"\n    }\n\t  remove_field => &#91;\"message\"]\n  }\n\n  # Remove leading and trailing spaces\n  mutate {\n    strip => &#91;\"#\", \"Host\", \"System\", \"Application\", \"Subsystem\", \"Module\", \"Severity\", \"Flags\", \"Timestamp\", \"Process\/Thread\"]\n  }\n\n  # Convert timestamp to @Timestamp (ensure it matches your log format)\n  date {\n    match => &#91;\"Timestamp\", \"yyyy.MM.dd HH:mm:ss.SSS\"]\n    target => \"@timestamp\"\n    timezone => \"UTC\"\n    locale => \"en\"  # Add locale to avoid parsing issues due to different formats or locales\n  }\n}\n\noutput {\n  # stdout {\n  #   codec => json_lines\n  # }\n\n  # Elasticsearch output (uncomment to enable)\n  elasticsearch {\n     hosts => &#91;\"http:\/\/linux0:9200\"] # Change it to your Elasticsearch host\n     index => \"wincc-traces-%{+YYYY.MM}\"\n     # user => \"elastic\"\n     # password => \"elastic\"\n  }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Start Logstash to collect log files. First, download Logstash (<a href=\"https:\/\/www.elastic.co\/downloads\/logstash\">https:\/\/www.elastic.co\/downloads\/logstash<\/a>) and extract it to C:\\Tools.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, run the following command to start Logstash using the specified configuration file:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>C:\\Tools\\logstash-8.17.3\\bin\\logstash.bat -f C:\\Tools\\logstash-siemens\\logstash.conf<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Forwarding Traces from WinCC Unified Panels<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><br>For WinCC Unified Panels, trace forwarding can be enabled, allowing traces to be captured with the WinCC Unified trace tool on a PC. The traces will then be also be written to files on the same PC (by the tool you started at Step 1).<\/p>\n\n\n<p>&#8220;C:\\Program Files\\Siemens\\Automation\\WinCCUnified\\bin\\RTILtraceTool.exe&#8221; -mode receiver -host <panel-host-ip> -tcp<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Visualizing Logs in Kibana<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once logs are stored in Elasticsearch, Kibana provides a powerful interface to explore and analyze them.<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>Open Kibana and navigate to\u00a0<strong>Stack Management > Index Patterns<\/strong>.<\/li>\n\n\n\n<li>Create a new index pattern matching\u00a0<code>wincc-traces-*<\/code>.<\/li>\n\n\n\n<li>Use\u00a0<strong>Discover<\/strong>\u00a0to explore logs and apply filters.<\/li>\n\n\n\n<li>Create dashboards and visualizations to monitor system health and performance.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"633\" src=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-1024x633.png\" alt=\"\" class=\"wp-image-1508\" srcset=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-1024x633.png 1024w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-300x185.png 300w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-768x475.png 768w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-1536x949.png 1536w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-06.27.00-2048x1265.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"750\" src=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-1024x750.png\" alt=\"\" class=\"wp-image-1512\" srcset=\"https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-1024x750.png 1024w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-300x220.png 300w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-768x562.png 768w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-1536x1125.png 1536w, https:\/\/www.rocworks.at\/wordpress\/wp-content\/uploads\/2025\/03\/Screenshot-2025-03-12-at-12.18.50-2048x1499.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>In industrial automation, logging and monitoring are crucial for maintaining system health and troubleshooting issues. Siemens WinCC Unified provides built-in tracing capabilities that. In this post I will show how to capture that traces to Elasticsearch to allow seamless log &hellip; <a href=\"https:\/\/www.rocworks.at\/wordpress\/?p=1506\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,33],"tags":[64],"class_list":["post-1506","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-wincc-unified","tag-winccunified"],"_links":{"self":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1506"}],"version-history":[{"count":6,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1506\/revisions"}],"predecessor-version":[{"id":1514,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1506\/revisions\/1514"}],"wp:attachment":[{"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocworks.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}