-
Notifications
You must be signed in to change notification settings - Fork 43
Replace tarantoolctl with tt (CE part) #3706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7d0e470
Replace tarantoolctl with tt -- draft
p7nov 3e7102a
Replace tarantoolctl with tt -- draft
p7nov e7e8481
Replace tarantoolctl with tt -- draft
p7nov 805808f
Replace tarantoolctl with tt -- draft
p7nov 229248a
Replace tarantoolctl with tt -- draft
p7nov 08791a4
Replace tarantoolctl with tt -- draft
p7nov ecb5694
Remove TODOs
p7nov 50d13b4
fix
p7nov 5e7a9c8
Move tarantooctl config to tarantoolctl.rst
p7nov 4ea511f
Fix wording in tarantooctl config
p7nov 058ab33
Fix
p7nov 4f6291b
Fix
p7nov 8ac849e
Rewrite logs section
p7nov 7fdc184
Apply suggestions from code review
p7nov 2e007d5
Apply suggestions from code review
p7nov 82ac74d
Review fix
p7nov f77a616
Fix build warnings
p7nov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,92 @@ | ||
.. _admin-logs: | ||
|
||
================================================================================ | ||
Logs | ||
================================================================================ | ||
==== | ||
|
||
Tarantool logs important events to a file, e.g. ``/var/log/tarantool/my_app.log``. | ||
To build the log file path, ``tarantoolctl`` takes the instance name, prepends | ||
the instance directory and appends “.log” extension. | ||
Each Tarantool instance logs important events to its own log file ``<instance-name>.log``. | ||
For instances started with :ref:`tt <tt-cli>`, the log location is defined by | ||
the ``log_dir`` parameter in the :ref:`tt configuration <tt-config>`. | ||
By default, it's ``/var/log/tarantool`` in the ``tt`` :ref:`system mode <config_modes>`, | ||
and the ``var/log/`` subdirectory of the ``tt`` working directory in the :ref:`local mode <config_modes>`. | ||
In the specified location, ``tt`` creates separate directories for each instance's logs. | ||
|
||
Let’s write something to the log file: | ||
To check how logging works, write something to the log using the :ref:`log <log-module>` module: | ||
|
||
.. code-block:: console | ||
|
||
$ tarantoolctl enter my_app | ||
/bin/tarantoolctl: connected to unix/:/var/run/tarantool/my_app.control | ||
unix/:/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers") | ||
--- | ||
... | ||
$ tt connect my_app | ||
• Connecting to the instance... | ||
• Connected to /var/run/tarantool/my_app.control | ||
|
||
/var/run/tarantool/my_app.control> require('log').info("Hello for the manual readers") | ||
|
||
Then check the logs: | ||
|
||
.. code-block:: console | ||
|
||
$ tail /var/log/tarantool/my_app.log | ||
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> version 1.7.3-382-g68ef3f6a9 | ||
2017-04-04 15:54:04.977 [29255] main/101/tarantoolctl C> log level 5 | ||
2017-04-04 15:54:04.978 [29255] main/101/tarantoolctl I> mapping 134217728 bytes for tuple arena... | ||
2017-04-04 15:54:04.985 [29255] iproto/101/main I> binary: bound to [::1]:3301 | ||
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovery start | ||
2017-04-04 15:54:04.986 [29255] main/101/tarantoolctl I> recovering from `/var/lib/tarantool/my_app/00000000000000000000.snap' | ||
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> ready to accept requests | ||
2017-04-04 15:54:04.988 [29255] main/101/tarantoolctl I> set 'checkpoint_interval' configuration option to 3600 | ||
2017-04-04 15:54:04.988 [29255] main/101/my_app I> Run console at unix/:/var/run/tarantool/my_app.control | ||
2017-04-04 15:54:04.989 [29255] main/106/console/unix/:/var/ I> started | ||
2017-04-04 15:54:04.989 [29255] main C> entering the event loop | ||
2017-04-04 15:54:47.147 [29255] main/107/console/unix/: I> Hello for the manual readers | ||
2023-09-12 18:13:00.396 [67173] main/111/guard of feedback_daemon/box.feedback_daemon V> metrics_collector restarted | ||
2023-09-12 18:13:00.396 [67173] main/103/-/box.feedback_daemon V> feedback_daemon started | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(14) = 0x1090077b4 | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(26) = 0x1090077ec | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007824 | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(24) = 0x10900785c | ||
2023-09-12 18:13:00.396 [67173] main/103/- D> memtx_tuple_new_raw_impl(39) = 0x109007894 | ||
2023-09-12 18:13:00.396 [67173] main/106/checkpoint_daemon I> scheduled next checkpoint for Tue Sep 12 19:44:34 2023 | ||
2023-09-12 18:13:00.396 [67173] main I> entering the event loop | ||
2023-09-12 18:13:11.656 [67173] main/114/console/unix/:/tarantool I> Hello for the manual readers | ||
|
||
.. _admin-logs-rotation: | ||
|
||
Log rotation | ||
------------ | ||
|
||
When :ref:`logging to a file <cfg_logging-log>`, the system administrator must ensure logs are | ||
rotated timely and do not take up all the available disk space. With | ||
``tarantoolctl``, log rotation is pre-configured to use ``logrotate`` program, | ||
which you must have installed. | ||
|
||
File ``/etc/logrotate.d/tarantool`` is part of the standard Tarantool | ||
distribution, and you can modify it to change the default behavior. This is what | ||
this file is usually like: | ||
|
||
.. code-block:: text | ||
|
||
/var/log/tarantool/*.log { | ||
daily | ||
size 512k | ||
missingok | ||
rotate 10 | ||
compress | ||
delaycompress | ||
create 0640 tarantool adm | ||
postrotate | ||
/usr/bin/tarantoolctl logrotate `basename ${1%%.*}` | ||
endscript | ||
} | ||
|
||
If you use a different log rotation program, you can invoke | ||
``tarantoolctl logrotate`` command to request instances to reopen their log | ||
files after they were moved by the program of your choice. | ||
|
||
Tarantool can write its logs to a log file, ``syslog`` or a program specified | ||
in the configuration file (see :ref:`log <cfg_logging-log>` parameter). | ||
|
||
By default, logs are written to a file as defined in ``tarantoolctl`` | ||
defaults. ``tarantoolctl`` automatically detects if an instance is using | ||
``syslog`` or an external program for logging, and does not override the log | ||
destination in this case. In such configurations, log rotation is usually | ||
handled by the external program used for logging. So, | ||
``tarantoolctl logrotate`` command works only if logging-into-file is enabled | ||
in the instance file. | ||
rotated timely and do not take up all the available disk space. | ||
To prevent log files from growing infinitely, ``tt`` automatically rotates instance | ||
logs. The following ``tt`` configuration parameters define the log rotation: | ||
``log_maxsize`` (in megabytes) and ``log_maxage`` (in days). When any of these | ||
limits is reached, the log is rotated. | ||
Additionally, there is the ``log_maxbackups`` parameter (the number of stored log | ||
files for an instance), which enables automatic removal of old log files. | ||
|
||
.. code-block:: yaml | ||
|
||
# tt.yaml | ||
tt: | ||
app: | ||
log_maxsize: 100 | ||
log_maxage: 3 | ||
log_maxbackups: 50 | ||
# ... | ||
|
||
There is also the :ref:`tt logrotate <tt-logrotate>` command that performs log | ||
rotation on demand. | ||
|
||
.. code-block:: bash | ||
|
||
tt logrotate my_app | ||
|
||
To learn about log rotation in the deprecated ``tarantoolctl`` utility, | ||
check its :ref:`documentation <tarantoolctl-log-rotation>`. | ||
|
||
|
||
.. _admin-logs-formats: | ||
|
||
Log formats | ||
----------- | ||
|
||
Tarantool can write its logs to a log file, to ``syslog``, or to a specified program | ||
through a pipe. | ||
|
||
File is the default log format for ``tt``. To send logs to a pipe or ``syslog``, | ||
specify the :ref:`box.cfg.log <cfg_logging-log>` parameter, for example: | ||
|
||
.. code-block:: lua | ||
|
||
box.cfg{log = '| cronolog tarantool.log'} | ||
-- or | ||
box.cfg{log = 'syslog:identity=tarantool,facility=user'} | ||
|
||
In such configurations, log rotation is usually handled by the external program | ||
used for logging. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.