opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.69k stars 893 forks source link

Logging on JSON format #5910

Open disaster37 opened 8 months ago

disaster37 commented 8 months ago

It can be usefull to have ability to log on JSON format with a property logging.json: true. It's nice to have log on stdout with Json format when it run on POD.

More over, I doesn't found a way to log on JSON format.

abbyhu2000 commented 8 months ago

This is a good idea, and can be picked up by anyone that is interested.

skumarp7 commented 6 months ago

Hi,

logging.json property is already there and i can see the logs coming in JSON format. Can you try setting "logging.json: true" in opensearch_dashboards.yml ?

disaster37 commented 6 months ago

Hi, thx for the tips.

It's work, but some logs are still in plain text when Dashboard starting. And others are prefixed by timestamps ...

Bad case:

2024-04-29T10:00:06.720996558Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["info","plugins-service"],"pid":1,"message":"Plugin \"dataSource\" is disabled."}

2024-04-29T10:00:07.040201454Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead

All logs on starting

{"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["info","plugins-service"],"pid":1,"message":"Plugin \"dataSourceManagement\" has been disabled since the following direct or transitive dependencies are missing or disabled: [dataSource]"}
2024-04-29T10:00:06.720996558Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["info","plugins-service"],"pid":1,"message":"Plugin \"dataSource\" is disabled."}
2024-04-29T10:00:06.721799426Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["info","plugins-service"],"pid":1,"message":"Plugin \"visTypeXy\" is disabled."}
{"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["warning","config","deprecation"],"pid":1,"message":"\"cpu.cgroup.path.override\" is deprecated and has been replaced by \"ops.cGroupOverrides.cpuPath\""}
2024-04-29T10:00:06.756643034Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["warning","config","deprecation"],"pid":1,"message":"\"cpuacct.cgroup.path.override\" is deprecated and has been replaced by \"ops.cGroupOverrides.cpuAcctPath\""}
2024-04-29T10:00:06.756862138Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["warning","config","deprecation"],"pid":1,"message":"\"opensearch.requestHeadersWhitelist\" is deprecated and has been replaced by \"opensearch.requestHeadersAllowlist\""}
[agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:06.955629774Z {"type":"log","@timestamp":"2024-04-29T10:00:06Z","tags":["info","plugins-system"],"pid":1,"message":"Setting up [52] plugins: [usageCollection,opensearchDashboardsUsageCollection,mapsLegacy,opensearchDashboardsLegacy,share,legacyExport,opensearchUiShared,embeddable,expressions,data,securityAnalyticsDashboards,home,apmOss,savedObjects,reportsDashboards,searchRelevanceDashboards,dashboard,mlCommonsDashboards,visualizations,visTypeVega,visTypeTimeline,visTypeTable,tileMap,visBuilder,visTypeMarkdown,visAugmenter,alertingDashboards,anomalyDetectionDashboards,regionMap,customImportMapDashboards,inputControlVis,ganttChartDashboards,visualize,queryWorkbenchDashboards,indexManagementDashboards,notificationsDashboards,management,indexPatternManagement,advancedSettings,console,dataExplorer,bfetch,charts,visTypeVislib,visTypeTagcloud,visTypeMetric,visTypeTimeseries,discover,savedObjectsManagement,securityDashboards,assistantDashboards,observabilityDashboards]"}
2024-04-29T10:00:07.040201454Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.144287761Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.147699579Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.154038466Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.379946807Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.382029412Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.
freeSocketTimeout instead
[agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
[agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.410168302Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.413784989Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.426378151Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
2024-04-29T10:00:07.446768329Z [agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
[agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead
{"type":"log","@timestamp":"2024-04-29T10:00:07Z","tags":["info","savedobjects-service"],"pid":1,"message":"Waiting until all OpenSearch nodes are compatible with OpenSearch Dashboards before starting saved objects migrations..."}
{"type":"log","@timestamp":"2024-04-29T10:00:08Z","tags":["info","savedobjects-service"],"pid":1,"message":"Starting saved objects migrations"}
{"type":"log","@timestamp":"2024-04-29T10:00:09Z","tags":["warning","cross-compatibility-service"],"pid":1,"message":"Starting cross compatibility service"}
2024-04-29T10:00:09.121507580Z {"type":"log","@timestamp":"2024-04-29T10:00:09Z","tags":["info","plugins-system"],"pid":1,"message":"Starting [52] plugins: [usageCollection,opensearchDashboardsUsageCollection,mapsLegacy,opensearchDashboardsLegacy,share,legacyExport,opensearchUiShared,embeddable,expressions,data,securityAnalyticsDashboards,home,apmOss,savedObjects,reportsDashboards,searchRelevanceDashboards,dashboard,mlCommonsDashboards,visualizations,visTypeVega,visTypeTimeline,visTypeTable,tileMap,visBuilder,visTypeMarkdown,visAugmenter,alertingDashboards,anomalyDetectionDashboards,regionMap,customImportMapDashboards,inputControlVis,ganttChartDashboards,visualize,queryWorkbenchDashboards,indexManagementDashboards,notificationsDashboards,management,indexPatternManagement,advancedSettings,console,dataExplorer,bfetch,charts,visTypeVislib,visTypeTagcloud,visTypeMetric,visTypeTimeseries,discover,savedObjectsManagement,securityDashboards,assistantDashboards,observabilityDashboards]"}
{"type":"log","@timestamp":"2024-04-29T10:00:10Z","tags":["listening","info"],"pid":1,"message":"Server running at https://0.0.0.0:5601"}
2024-04-29T10:00:11.277509388Z {"type":"log","@timestamp":"2024-04-29T10:00:11Z","tags":["info","http","server","OpenSearchDashboards"],"pid":1,"message":"http server running at https://0.0.0.0:5601"}
{"type":"response","@timestamp":"2024-04-29T10:00:13Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":270,"contentLength":9},"message":"GET /app/dashboard 302 270ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:00:13Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":37,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 37ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:00:23Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":3,"contentLength":9},"message":"GET /app/dashboard 302 3ms - 9.0B"}
2024-04-29T10:00:23.324976910Z {"type":"response","@timestamp":"2024-04-29T10:00:23Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":11,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 11ms - 9.0B"}
2024-04-29T10:00:33.311853730Z {"type":"response","@timestamp":"2024-04-29T10:00:33Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":3,"contentLength":9},"message":"GET /app/dashboard 302 3ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:00:33Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":14,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 14ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:00:43Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":4,"contentLength":9},"message":"GET /app/dashboard 302 4ms - 9.0B"}
2024-04-29T10:00:43.330793922Z {"type":"response","@timestamp":"2024-04-29T10:00:43Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":15,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 15ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:00:53Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":3,"contentLength":9},"message":"GET /app/dashboard 302 3ms - 9.0B"}
2024-04-29T10:00:53.328433208Z {"type":"response","@timestamp":"2024-04-29T10:00:53Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":15,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 15ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:03Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":2,"contentLength":9},"message":"GET /app/dashboard 302 2ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:03Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":14,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 14ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:13Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":2,"contentLength":9},"message":"GET /app/dashboard 302 2ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:13Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":13,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 13ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:23Z","tags":[],"pid":1,"method":"get","statusCode":302,"req":{"url":"/app/dashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":302,"responseTime":2,"contentLength":9},"message":"GET /app/dashboard 302 2ms - 9.0B"}
{"type":"response","@timestamp":"2024-04-29T10:01:23Z","tags":[],"pid":1,"method":"get","statusCode":200,"req":{"url":"/app/login?nextUrl=%2Fapp%2Fdashboard","method":"get","headers":{"host":"127.0.0.1:5601","user-agent":"curl/8.5.0","accept":"*/*"},"remoteAddress":"127.0.0.1","userAgent":"curl/8.5.0"},"res":{"statusCode":200,"responseTime":13,"contentLength":9},"message":"GET /app/login?nextUrl=%2Fapp%2Fdashboard 200 13ms - 9.0B"}
pratikshavyas commented 3 months ago

Hi @disaster37 Can you please share in which version was this issue observed? I have tried and did not see logs prefixed with timestamps.

disaster37 commented 1 month ago

I use Opensearch 2.16.0 Maybee the timestamp prefix is added by docker engine / rancher when I display the stdout logs.

Moreover, I think the real problem is some log are not in JSON format. Like:

[agentkeepalive:deprecated] options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead