diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-10-27 10:35:36 +0300 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-10-27 10:35:36 +0300 |
| commit | dadbaab24d66685db0a2a6655bd75cdbb19eb929 (patch) | |
| tree | 920e22fe1d14664a658bea827d95b6bda0ed4d46 /doc/examples.md | |
| parent | f6bcd5be51a427747be8058d7a7b9887bc2670ca (diff) | |
Update docs to reflect some of the changes made in the past
Diffstat (limited to 'doc/examples.md')
| -rw-r--r-- | doc/examples.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/examples.md b/doc/examples.md index 91ab7f2..6c23120 100644 --- a/doc/examples.md +++ b/doc/examples.md @@ -15,6 +15,12 @@ The following example demonstrates how to follow logs of multiple servers at onc  +You can also use the shorthand version: + +```shell +% dtail --servers serverlist.txt --regex STAT "/var/log/service/*.log" +``` + ## Aggregating logs To run ad-hoc MapReduce aggregations on newly written log lines, you also must add a query. The following example follows all remote log lines and prints out every 5 seconds the top 10 servers with the most average free memory. To run a MapReduce query across log lines written in the past, please use the ``dmap`` command instead. @@ -29,6 +35,14 @@ For MapReduce queries to work, you have to ensure that DTail supports your log f  +You can also use the shorthand version: + +```shell +% dtail --servers serverlist.txt \ + 'select avg(memfree), $hostname from MCVMSTATS group by $hostname order by avg(memfree) limit 10 interval 5' \ + '/var/log/service/*.log' +``` + # How to use ``dcat`` The following example demonstrates how to cat files (display the full content of the files) of multiple servers at once. The servers are provided as a comma-separated list this time. @@ -40,6 +54,13 @@ The following example demonstrates how to cat files (display the full content of  +You can also use the shorthand version: + +```shell +% dcat --servers serv-011.lan.example.org,serv-012.lan.example.org,serv-013.lan.example.org \ + /etc/hostname +``` + # How to use ``dgrep`` The following example demonstrates how to grep files (display only the lines which match a given regular expression) of multiple servers at once. In this example, we look after the swap partition in ``/etc/fstab``. We do that only on the first 20 servers from ``serverlist.txt``. ``dgrep`` is also very useful for searching log files of the past. @@ -52,6 +73,14 @@ The following example demonstrates how to grep files (display only the lines whi  +You can also use the shorthand version: + +TODO: Auto detect that swap is a regex. +```shell +% dgrep --servers <(head -n 20 serverlist.txt) \ + /etc/fstab swap +``` + # How to use ``dmap`` To run a MapReduce aggregation over logs written in the past, the ``dmap`` command can be used. For example, the following command aggregates all MapReduce fields of all the records and calculates the average memory free grouped by day of the month, hour, minute and the server hostname. ``dmap`` will print interim results every few seconds. The final product, however, will be written to file ``mapreduce.csv``. @@ -65,3 +94,11 @@ To run a MapReduce aggregation over logs written in the past, the ``dmap`` comma Remember: For that to work, you have to make sure that DTail supports your log format. You can either use the ones already defined in ``internal/mapr/log format`` or add an extension to support a custom log format.  + +You can also use the shorthand version: + +```shell +% dmap --servers serv-011.lan.example.org,serv-012.lan.example.org,serv-013.lan.example.org,serv-021.lan.example.org,serv-022.lan.example.org,serv-023.lan.example.org \ + 'select avg(memfree), $day, $hour, $minute, $hostname from MCVMSTATS group by $day, $hour, $minute, $hostname order by avg(memfree) limit 10 outfile mapreduce.csv' \ + "/var/log/service/*.log" +``` |
