forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
99 lines
14 KiB
HTML
99 lines
14 KiB
HTML
<a name="mrs_01_0471"></a><a name="mrs_01_0471"></a>
|
|
|
|
<h1 class="topictitle1">Using an MRS Client to Operate OpenTSDB Metric Data</h1>
|
|
<div id="body1589421636429"><p id="mrs_01_0471__p8060118">You can perform an interactive operation on an MRS cluster client. For a cluster with Kerberos authentication enabled, the user must belong to the <strong id="mrs_01_0471__b20199210365328">opentsdb</strong>, <strong id="mrs_01_0471__b4296692115328">hbase</strong>, <strong id="mrs_01_0471__b1316213405328">opentsdbgroup</strong>, and <strong id="mrs_01_0471__b12600965545328">supergroup</strong> groups and have the HBase permission.</p>
|
|
<div class="section" id="mrs_01_0471__section482010192610"><h4 class="sectiontitle">Prerequisites</h4><ul id="mrs_01_0471__ul18739582619"><li id="mrs_01_0471__li88748512263">The password of user <strong id="mrs_01_0471__b3187125435328">admin</strong> has been obtained. The password of user <strong id="mrs_01_0471__b15157674565328">admin</strong> is specified by the user during MRS cluster creation.</li><li id="mrs_01_0471__li19874195132611">The cluster client has been installed, for example, in the <strong id="mrs_01_0471__b4249148072">/opt/client</strong> directory. The client directory in the following operations is only an example. Change it based on the actual installation directory onsite. For details about how to update a client, see <a href="mrs_01_2130.html">Updating a Client (Versions Earlier Than 3.x)</a>.</li></ul>
|
|
</div>
|
|
<div class="section" id="mrs_01_0471__section137578192714"><h4 class="sectiontitle">Using a Client</h4><ol id="mrs_01_0471__ol123161142122712"><li id="mrs_01_0471__li15316164212277"><span>If Kerberos authentication is enabled for the current cluster, log in to MRS Manager and create a user that belongs to the <strong id="mrs_01_0471__b20848133345328">opentsdb</strong>, <strong id="mrs_01_0471__b5256465595328">hbase</strong>, <strong id="mrs_01_0471__b7951291565328">opentsdbgroup</strong>, and <strong id="mrs_01_0471__b15818045365328">supergroup</strong> groups and has the HBase permission, for example, <strong id="mrs_01_0471__b10608253895328">opentsdbuser</strong>. If Kerberos authentication is disabled for the current cluster, skip this step.</span></li><li id="mrs_01_0471__li1273631718297"><span>Prepare a client based on service conditions and log in to the node where the client is installed.</span><p><p id="mrs_01_0471__p1662112010299">For example, if you have updated the client on the Master2 node, log in to the Master2 node to use the client. For details, see <a href="mrs_01_2130.html">Updating a Client (Versions Earlier Than 3.x)</a>.</p>
|
|
</p></li><li id="mrs_01_0471__li2585123717291"><span>Run the following command to switch the user:</span><p><p id="mrs_01_0471__p5570048132910"><strong id="mrs_01_0471__b757014820292">sudo su - omm</strong></p>
|
|
</p></li><li id="mrs_01_0471__li1173965822910"><span>Run the following command to switch to the client directory, for example, <strong id="mrs_01_0471__b10037350745328">/opt/client</strong>.</span><p><p id="mrs_01_0471__p177491758132911"><strong id="mrs_01_0471__b67491958132912">cd /opt/client</strong></p>
|
|
</p></li><li id="mrs_01_0471__li1328610293018"><span>Run the following command to configure environment variables:</span><p><p id="mrs_01_0471__p1029513220305"><strong id="mrs_01_0471__b102953223015">source bigdata_env</strong></p>
|
|
</p></li><li id="mrs_01_0471__li3644101353316"><span>If Kerberos authentication is enabled for the current cluster, run the following command to authenticate the current user. If Kerberos authentication is disabled for the current cluster, skip this step.</span><p><ul id="mrs_01_0471__ul134571621617"><li id="mrs_01_0471__li145713671615">If the user is a human-machine user, run the <strong id="mrs_01_0471__b10215124251620">kinit opentsdbuser</strong> command to authenticate the user.</li><li id="mrs_01_0471__li0966174320168">If the user is a machine-machine user, download the user authentication credential file, and save and decompress it to obtain the user's <strong id="mrs_01_0471__b11241086905328">user.keytab</strong> and <strong id="mrs_01_0471__b20305343035328">krb5.conf</strong> files. Go to the decompressed <strong id="mrs_01_0471__b5742218385328">user.keytab</strong> directory, and run the <strong id="mrs_01_0471__b8737437555328">kinit -kt user.keytab opentsdbuser</strong> command to authenticate the user.</li></ul>
|
|
</p></li><li id="mrs_01_0471__li1390815853011"><span>Operate the OpenTSDB data. For details, see <a href="#mrs_01_0471__section46629451460">Operating Data</a>.</span></li></ol>
|
|
</div>
|
|
<div class="section" id="mrs_01_0471__section46629451460"><a name="mrs_01_0471__section46629451460"></a><a name="section46629451460"></a><h4 class="sectiontitle">Operating Data</h4><ul id="mrs_01_0471__ul2477195220472"><li id="mrs_01_0471__li247716525474">Viewing help information<p id="mrs_01_0471__p243994319491"><a name="mrs_01_0471__li247716525474"></a><a name="li247716525474"></a>Run the <strong id="mrs_01_0471__b11455161505018">tsdb</strong> command to print all commands supported by OpenTSDB, for example, <strong id="mrs_01_0471__b3397196835328">fsck</strong>, <strong id="mrs_01_0471__b4444200635328">import</strong>, <strong id="mrs_01_0471__b11693578415328">mkmetric</strong>, <strong id="mrs_01_0471__b13830158975328">query</strong>, <strong id="mrs_01_0471__b9904533055328">tsd</strong>, <strong id="mrs_01_0471__b12663309285328">scan</strong>, <strong id="mrs_01_0471__b4274591305328">search</strong>, <strong id="mrs_01_0471__b8483095375328">uid</strong>, and <strong id="mrs_01_0471__b10922940445328">version</strong>.</p>
|
|
<p id="mrs_01_0471__p03649554490">Command output:</p>
|
|
<pre class="screen" id="mrs_01_0471__screen6126137115011">tsdb: error: unknown command ''
|
|
usage: tsdb <command> [args]
|
|
Valid commands: fsck, import, mkmetric, query, tsd, scan, search, uid, version</pre>
|
|
</li><li id="mrs_01_0471__li1389105874715">Creating an OpenTSDB metric<p id="mrs_01_0471__p10636347175115"><a name="mrs_01_0471__li1389105874715"></a><a name="li1389105874715"></a>Run the <strong id="mrs_01_0471__b131221845195419">tsdb mkmetric</strong> command to create a metric. For example, run the <strong id="mrs_01_0471__b7197173045328">tsdb mkmetric sys.cpu.user</strong> command to create a metric named <strong id="mrs_01_0471__b10050445875328">sys.cpu.user</strong>.</p>
|
|
<p id="mrs_01_0471__p116365479514">Command output:</p>
|
|
<pre class="screen" id="mrs_01_0471__screen12319742195115">Start run net.opentsdb.tools.UidManager, args: assign metrics sys.cpu.user
|
|
metrics sys.cpu.user: [0, 0, 6]</pre>
|
|
</li><li id="mrs_01_0471__li181492391165">Importing data to the OpenTSDB metric<ol id="mrs_01_0471__ol1295817494179"><li id="mrs_01_0471__li19959104941714">Prepare a metric file, for example, the <strong id="mrs_01_0471__b20292336745328">importData.txt</strong> file that contains following information.<p id="mrs_01_0471__p814025561813">sys.cpu.user 1356998400 41 host=web01 cpu=0</p>
|
|
<p id="mrs_01_0471__p17140155515189">sys.cpu.user 1356998401 42 host=web01 cpu=0</p>
|
|
<p id="mrs_01_0471__p171403558183">sys.cpu.user 1356998402 44 host=web01 cpu=0</p>
|
|
<p id="mrs_01_0471__p41401555191814">sys.cpu.user 1356998403 47 host=web01 cpu=0</p>
|
|
<p id="mrs_01_0471__p814011554188">sys.cpu.user 1356998404 42 host=web01 cpu=0</p>
|
|
<p id="mrs_01_0471__p20140135514184">sys.cpu.user 1356998405 42 host=web01 cpu=0</p>
|
|
</li><li id="mrs_01_0471__li14648183411812">Run the <strong id="mrs_01_0471__b339615566404">tsdb import</strong> command to import metric data. For example, run the <strong id="mrs_01_0471__b12251290375328">tsdb import importData.txt</strong> command to import the <strong id="mrs_01_0471__b21217749605328">importData.txt</strong> file.<pre class="screen" id="mrs_01_0471__screen185761059122116">Start run net.opentsdb.tools.TextImporter, args: importData.txt
|
|
2019-06-26
|
|
15:45:22,091 INFO [main] TextImporter:
|
|
reading from file:importData.txt
|
|
2019-06-26
|
|
15:45:22,102 INFO [main] TextImporter:
|
|
Processed importData.txt in 11 ms, 6 data points (545.5 points/s)
|
|
2019-06-26
|
|
15:45:22,102 INFO [main] TextImporter:
|
|
Total: imported 6 data points in 0.012s (504.0 points/s)</pre>
|
|
</li></ol>
|
|
</li><li id="mrs_01_0471__li1131619166488">Querying the OpenTSDB metric<p id="mrs_01_0471__p1567265118574"><a name="mrs_01_0471__li1131619166488"></a><a name="li1131619166488"></a>Run the <strong id="mrs_01_0471__b37221559175717">tsdb uid metrics</strong> command to obtain the metric stored in OpenTSDB. For example, run the <strong id="mrs_01_0471__b2915473635328">tsdb uid metrics sys.cpu.user</strong> command to query the data of the <strong id="mrs_01_0471__b6483136735328">sys.cpu.user</strong> metric.</p>
|
|
<p id="mrs_01_0471__p15113085813">Command output:</p>
|
|
<pre class="screen" id="mrs_01_0471__screen10402540145812">Start run net.opentsdb.tools.UidManager, args: metrics sys.cpu.user
|
|
metrics sys.cpu.user: [0, 0, 6]</pre>
|
|
<p id="mrs_01_0471__p670615320461">To obtain more information, run the <strong id="mrs_01_0471__b134159512166">tsdb uid</strong> command.</p>
|
|
<pre class="screen" id="mrs_01_0471__screen126171812191616">Start run net.opentsdb.tools.UidManager, args:
|
|
Not enough arguments
|
|
Usage: uid <subcommand> args
|
|
Sub commands:
|
|
grep [kind] <RE>: Finds matching IDs.
|
|
assign <kind> <name> [names]: Assign an ID for the given name(s).
|
|
rename <kind> <name> <newname>: Renames this UID.
|
|
delete <kind> <name>: Deletes this UID.
|
|
fsck: [fix] [delete_unknown] Checks the consistency of UIDs.
|
|
fix - Fix errors. By default errors are logged.
|
|
delete_unknown - Remove columns with unknown qualifiers.
|
|
The "fix" flag must be supplied as well.
|
|
[kind] <name>: Lookup the ID of this name.
|
|
[kind] <ID>: Lookup the name of this ID.
|
|
metasync: Generates missing TSUID and UID meta entries, updates created timestamps
|
|
metapurge: Removes meta data entries from the UID table
|
|
treesync: Process all timeseries meta objects through tree rules
|
|
treepurge <id> [definition]: Purge a tree and/or the branches from storage. Provide an integer Tree ID and optionally add "true" to delete the tree definition
|
|
Example values for [kind]: metrics, tagk (tag name), tagv (tag value).
|
|
--config=PATH Path to a configuration file (default: Searches for file see docs).
|
|
--idwidth=N Number of bytes on which the UniqueId is encoded.
|
|
--ignore-case Ignore case distinctions when matching a regexp.
|
|
--table=TABLE Name of the HBase table where to store the time series (default: tsdb).
|
|
--uidtable=TABLE Name of the HBase table to use for Unique IDs (default: tsdb-uid).
|
|
--verbose Print more logging messages and not just errors.
|
|
--zkbasedir=PATH Path under which is the znode for the -ROOT- region (default: /hbase).
|
|
--zkquorum=SPEC Specification of the ZooKeeper quorum to use (default: localhost).
|
|
-i Short for --ignore-case.
|
|
-v Short for --verbose.</pre>
|
|
</li><li id="mrs_01_0471__li1371919918227">Scanning the OpenTSDB metric data<p id="mrs_01_0471__p19209743142217"><a name="mrs_01_0471__li1371919918227"></a><a name="li1371919918227"></a>Run the <strong id="mrs_01_0471__b19631860845328">tsdb query</strong> command to query the imported metric data in batches. The command format is as follows: <strong id="mrs_01_0471__b9133485815328"><em id="mrs_01_0471__i4151438585328">tsdb query <START-DATE> <END-DATE> <aggregator> <metric> <tagk=tagv></em></strong>. For example, run the <strong id="mrs_01_0471__b651528785328">tsdb query 0 1h-ago sum sys.cpu.user host=web01</strong> command.</p>
|
|
<pre class="screen" id="mrs_01_0471__screen3702164192414">Start run net.opentsdb.tools.CliQuery, args: 0 1h-ago sum sys.cpu.user host=web01
|
|
sys.cpu.user 1356998400000 41 {host=web01, cpu=0}
|
|
sys.cpu.user 1356998401000 42 {host=web01, cpu=0}
|
|
sys.cpu.user 1356998402000 44 {host=web01, cpu=0}
|
|
sys.cpu.user 1356998403000 47 {host=web01, cpu=0}
|
|
sys.cpu.user 1356998404000 42 {host=web01, cpu=0}
|
|
sys.cpu.user 1356998405000 42 {host=web01, cpu=0}</pre>
|
|
<div class="note" id="mrs_01_0471__note0958133015138"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_0471__p17959163071318"><strong id="mrs_01_0471__b2682279055328"><START-DATE></strong>: start time of the metric to be queried</p>
|
|
<p id="mrs_01_0471__p449118296194"><strong id="mrs_01_0471__b15928918995328"><END-DATE></strong>: end time of the metric to be queried</p>
|
|
<p id="mrs_01_0471__p1061723531912"><strong id="mrs_01_0471__b19447047095328"><aggregator></strong>: aggregation mode of the data query</p>
|
|
<p id="mrs_01_0471__p142970553190"><strong id="mrs_01_0471__b19256360935328"><metric></strong>: name of the metric to be queried</p>
|
|
<p id="mrs_01_0471__p112379415192"><strong id="mrs_01_0471__b4314384095328"><tagk=tagv></strong>: key and value of a tag</p>
|
|
</div></div>
|
|
</li><li id="mrs_01_0471__li2098942742219">Deleting the imported OpenTSDB metric<p id="mrs_01_0471__p9173147112517"><a name="mrs_01_0471__li2098942742219"></a><a name="li2098942742219"></a>Run the <strong id="mrs_01_0471__b1834313558266">tsdb uid delete</strong> command to delete the imported metric and its value. For example, to delete the <strong id="mrs_01_0471__b5641415805328">sys.cpu.user</strong> metric, run the <strong id="mrs_01_0471__b19727202045328">tsdb uid delete metrics sys.cpu.user</strong> command.</p>
|
|
<pre class="screen" id="mrs_01_0471__screen1192153832717">Start run net.opentsdb.tools.UidManager, args: delete metrics sys.cpu.user</pre>
|
|
</li></ul>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_0599.html">Using OpenTSDB</a></div>
|
|
</div>
|
|
</div>
|
|
|