How to get metrics from tgtd

George Shuklin
OpsOps
Published in
1 min readOct 4, 2022

I’ve tried to find a way to gather metrics from iscsi TGT. I found nothing. No metrics, no exporters, no counters. Documentation is silent, internet is silent. It sounded like there is no metrics from tgt-admin or tgtadm or tgtd at all.

But after reading source code iscsi_if.h and tgtadm.c, I found, there are, actually metrics. Tgtd is very old, so they are called ‘stats’. And there is undocumented feature:

tgtadm --mode system --op stat

Example of output of tgtd (output is too long to show as text):

tgtd metrics ..ew… stats

Lun0 is a controller, and lun 1 is the actual device.

  • rd_subm is submitted reads (in bytes and operations == cmds)
  • rd_done is finished reads (the same, bytes and ops)
  • wr_subm is submitted writes
  • wr_done is finished writes
  • errs is an error counter.

There is no ready-made exporter, but it should be easy to write, I believe. Advise for future exporter writer: to support multiple instances TGTD (multiple TGT_IPC_SOCKET)

--

--

George Shuklin
OpsOps

I work at Servers.com, most of my stories are about Ansible, Ceph, Python, Openstack and Linux. My hobby is Rust.