133 lines
19 KiB
HTML
133 lines
19 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-US">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>Create Token | Nezha Monitoring</title>
|
|
<meta name="description" content="Nezha Monitoring is a lightweight O&M tool">
|
|
<link rel="stylesheet" href="/assets/style.17a88c2e.css">
|
|
<link rel="modulepreload" href="/assets/app.9c3473cb.js">
|
|
<link rel="modulepreload" href="/assets/en_US_guide_api.md.d519a59e.lean.js">
|
|
|
|
<meta name="twitter:title" content="Create Token | Nezha Monitoring">
|
|
<meta property="og:title" content="Create Token | Nezha Monitoring">
|
|
</head>
|
|
<body>
|
|
<div id="app"><!--[--><div class="theme"><header class="nav-bar" data-v-675d8756><div class="sidebar-button" data-v-675d8756><svg class="icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z" class></path></svg></div><a class="nav-bar-title" href="/en_US/" aria-label="Nezha Monitoring, back to home" data-v-675d8756 data-v-cc01ef16><!----> Nezha Monitoring</a><div class="flex-grow" data-v-675d8756></div><div class="nav" data-v-675d8756><nav class="nav-links" data-v-675d8756 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/api.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/api.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav></div><!--[--><!--]--></header><aside class="sidebar" data-v-83e92a68><nav class="nav-links nav" data-v-83e92a68 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/api.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/api.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav><!--[--><!--]--><ul class="sidebar-links" data-v-83e92a68><!--[--><li class="sidebar-link"><p class="sidebar-link-item">Installation Manual</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboard">Install Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/agent">Install Agent</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Admin Panel</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/servers">Servers</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/services">Services</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/tasks">Tasks</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/notifications">Notifications</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/settings">Settings</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item active" href="/en_US/guide/api">API</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#create-token">Create Token</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#authentication-method">Authentication method</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#how-to-use">How to use</a><!----></li></ul></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">FAQ</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q2">Let the Agent start/on-line, and the self-test process of the problem</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q3">Reverse Proxy gRPC Port (support Cloudflare CDN)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q4">Real-time channel disconnection/online terminal connection failure</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q5">How do I migrate my data to the new server and restore my backups?</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q6">How to set up a monthly reset of data statistics?</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Troubleshooting Guide</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboardq">Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/agentq">Agent</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/loginq">Login</a><!----></li></ul></li><!--]--></ul><!--[--><!--]--></aside><div class="sidebar-mask"></div><main class="page" data-v-7eddb2c4><div class="container" data-v-7eddb2c4><!--[--><!--]--><div style="position:relative;" class="content" data-v-7eddb2c4><div><p><strong>Nezha Monitoring now supports querying the status information of the Agent in the Dashboard using the API</strong></p><h2 id="create-token" tabindex="-1">Create Token <a class="header-anchor" href="#create-token" aria-hidden="true">#</a></h2><p>API allows Token authentication method and Cookies authentication method<br> To create a new Token, after entering the admin panel, click on the avatar in the upper right corner and select "API Token" to enter the Token management page<br> Click "Add Token" and after customizing the notes, click "Add"<br> To delete a Token, please select the corresponding Token and click the delete icon on the right</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>Token is the authentication tool of API, it is very important for your Dashboard's information security, please don't leak your Token to others</p></div><h2 id="authentication-method" tabindex="-1">Authentication method <a class="header-anchor" href="#authentication-method" aria-hidden="true">#</a></h2><p>Token authentication method:</p><div class="language-"><pre><code>Request Headers:
|
|
Authorization: Token
|
|
</code></pre></div><h2 id="how-to-use" tabindex="-1">How to use <a class="header-anchor" href="#how-to-use" aria-hidden="true">#</a></h2><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>The negative timestamp in the example below is (0000-00-00)<br> It is currently used to indicate that the Agent has never reported since the Dashboard went live<br> However, it is not recommended to use positivity or negativity to determine the status</p></div><div class="tip custom-block"><p class="custom-block-title">TIP</p><p><strong>The request method is <code>Get</code> and the return format is <code>JSON</code>.</strong></p></div><ul><li>Get a list of servers: <code>GET /api/v1/server/list?tag=</code><br> query: tag (ServerTag means the group of servers, if this value is provided, only the servers in this group are queried)</li></ul><p>JSON Return Example:</p><div class="language-"><pre><code>{
|
|
"code": 0,
|
|
"message": "success",
|
|
"result": [
|
|
{
|
|
"id": 1,
|
|
"name": "Server1",
|
|
"tag": "Tag1",
|
|
"last_active": 1653014667,
|
|
"ipv4": "1.1.1.1",
|
|
"ipv6": "",
|
|
"valid_ip": "1.1.1.1"
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Server2",
|
|
"tag": "Tag2",
|
|
"last_active": -62135596800,
|
|
"ipv4": "",
|
|
"ipv6": "",
|
|
"valid_ip": ""
|
|
}
|
|
]
|
|
}
|
|
</code></pre></div><ul><li>Get server details: <code>GET /api/v1/server/details?id=&tag=</code><br> query: id (ServerID. Multiple IDs are separated by commas, provide this value to query the server corresponding to the ID, while ignoring the tag value)<br> query: tag (ServerTag, if this value is provided, only the servers in this group are queried)</li></ul><p>JSON Return Example:</p><div class="language-"><pre><code>{
|
|
"code": 0,
|
|
"message": "success",
|
|
"result": [
|
|
{
|
|
"id": 1,
|
|
"name": "Server1",
|
|
"tag": "Tag1",
|
|
"last_active": 1653015042,
|
|
"ipv4": "1.1.1.1",
|
|
"ipv6": "",
|
|
"valid_ip": "1.1.1.1",
|
|
"host": {
|
|
"Platform": "darwin",
|
|
"PlatformVersion": "12.3.1",
|
|
"CPU": [
|
|
"Apple M1 Pro 1 Physical Core"
|
|
],
|
|
"MemTotal": 17179869184,
|
|
"DiskTotal": 2473496842240,
|
|
"SwapTotal": 0,
|
|
"Arch": "arm64",
|
|
"Virtualization": "",
|
|
"BootTime": 1652683962,
|
|
"CountryCode": "hk",
|
|
"Version": ""
|
|
},
|
|
"status": {
|
|
"CPU": 17.330210772540017,
|
|
"MemUsed": 14013841408,
|
|
"SwapUsed": 0,
|
|
"DiskUsed": 2335048912896,
|
|
"NetInTransfer": 2710273234,
|
|
"NetOutTransfer": 695454765,
|
|
"NetInSpeed": 10806,
|
|
"NetOutSpeed": 5303,
|
|
"Uptime": 331080,
|
|
"Load1": 5.23486328125,
|
|
"Load5": 4.873046875,
|
|
"Load15": 3.99267578125,
|
|
"TcpConnCount": 195,
|
|
"UdpConnCount": 70,
|
|
"ProcessCount": 437
|
|
}
|
|
},
|
|
{
|
|
"id": 2,
|
|
"name": "Server2",
|
|
"tag": "Tag2",
|
|
"last_active": -62135596800,
|
|
"ipv4": "",
|
|
"ipv6": "",
|
|
"valid_ip": "",
|
|
"host": {
|
|
"Platform": "",
|
|
"PlatformVersion": "",
|
|
"CPU": null,
|
|
"MemTotal": 0,
|
|
"DiskTotal": 0,
|
|
"SwapTotal": 0,
|
|
"Arch": "",
|
|
"Virtualization": "",
|
|
"BootTime": 0,
|
|
"CountryCode": "",
|
|
"Version": ""
|
|
},
|
|
"status": {
|
|
"CPU": 0,
|
|
"MemUsed": 0,
|
|
"SwapUsed": 0,
|
|
"DiskUsed": 0,
|
|
"NetInTransfer": 0,
|
|
"NetOutTransfer": 0,
|
|
"NetInSpeed": 0,
|
|
"NetOutSpeed": 0,
|
|
"Uptime": 0,
|
|
"Load1": 0,
|
|
"Load5": 0,
|
|
"Load15": 0,
|
|
"TcpConnCount": 0,
|
|
"UdpConnCount": 0,
|
|
"ProcessCount": 0
|
|
}
|
|
}
|
|
]
|
|
}
|
|
</code></pre></div></div></div><footer class="page-footer" data-v-7eddb2c4 data-v-07c132fc><div class="edit" data-v-07c132fc><div class="edit-link" data-v-07c132fc data-v-1ed99556><a class="link" href="https://github.com/nezhahq/nezhahq.github.io/edit/main/docs/en_US/guide/api.md" target="_blank" rel="noopener noreferrer" data-v-1ed99556>Edit this page on GitHub <svg class="icon outbound icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-1ed99556><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div><div class="updated" data-v-07c132fc><!----></div></footer><div class="next-and-prev-link" data-v-7eddb2c4 data-v-38ede35f><div class="container" data-v-38ede35f><div class="prev" data-v-38ede35f><a class="link" href="/en_US/guide/settings" data-v-38ede35f><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-prev" data-v-38ede35f><path d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z"></path></svg><span class="text" data-v-38ede35f>Settings</span></a></div><div class="next" data-v-38ede35f><a class="link" href="/en_US/guide/q2" data-v-38ede35f><span class="text" data-v-38ede35f>Let the Agent start/on-line, and the self-test process of the problem</span><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-next" data-v-38ede35f><path d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z"></path></svg></a></div></div></div><!--[--><!--]--></div></main></div><!----><!--]--></div>
|
|
<script>__VP_HASH_MAP__ = JSON.parse("{\"developer_index.md\":\"87b2164a\",\"developer_l10n.md\":\"423ded75\",\"developer_theme.md\":\"4c18ce46\",\"en_us_developer_index.md\":\"e3a7643d\",\"en_us_developer_l10n.md\":\"a6ae6fae\",\"en_us_developer_theme.md\":\"68f6eb4c\",\"en_us_guide_agent.md\":\"be3521e6\",\"en_us_guide_agentq.md\":\"1f622bb1\",\"en_us_guide_api.md\":\"d519a59e\",\"en_us_guide_dashboard.md\":\"0e405f14\",\"en_us_guide_dashboardq.md\":\"6d86f723\",\"en_us_guide_loginq.md\":\"373629be\",\"en_us_guide_notifications.md\":\"3d75e558\",\"en_us_guide_q2.md\":\"39fe67c6\",\"en_us_guide_q3.md\":\"4e2fdc99\",\"en_us_guide_q4.md\":\"f5b1d1b8\",\"en_us_guide_q5.md\":\"415f1b49\",\"en_us_guide_q6.md\":\"40fabb53\",\"en_us_guide_servers.md\":\"547e489b\",\"en_us_guide_services.md\":\"5b8d6f74\",\"en_us_guide_settings.md\":\"6147c70c\",\"en_us_guide_tasks.md\":\"1aa90124\",\"en_us_index.md\":\"065e3776\",\"guide_agent.md\":\"996d4a27\",\"guide_agentq.md\":\"e0b674d5\",\"guide_api.md\":\"52e8f873\",\"guide_dashboard.md\":\"26bb8f08\",\"guide_dashboardq.md\":\"65877597\",\"guide_loginq.md\":\"1774e95f\",\"guide_notifications.md\":\"9e6d6d2d\",\"guide_q1.md\":\"02a52d8b\",\"guide_q2.md\":\"659c70e9\",\"guide_q3.md\":\"dc9bcac4\",\"guide_q4.md\":\"df8db5fe\",\"guide_q5.md\":\"6679febd\",\"guide_q6.md\":\"c6ca959a\",\"guide_servers.md\":\"bfc8c36a\",\"guide_services.md\":\"08a3a1d5\",\"guide_settings.md\":\"84bf7e05\",\"guide_tasks.md\":\"1d8bc936\",\"index.md\":\"0a71af9a\"}")</script>
|
|
<script type="module" async src="/assets/app.9c3473cb.js"></script>
|
|
|
|
</body>
|
|
</html> |