114 lines
7.2 KiB
JavaScript
114 lines
7.2 KiB
JavaScript
import{_ as t,c as o,o as e,d as u}from"./app.2c402e15.js";const v='{"title":"Create Token","description":"","frontmatter":{},"headers":[{"level":2,"title":"Create Token","slug":"create-token"},{"level":2,"title":"Authentication method","slug":"authentication-method"},{"level":2,"title":"How to use","slug":"how-to-use"}],"relativePath":"en_US/guide/api.md"}',n={},q=u(`<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>`,16),a=[q];function i(r,s,d,l,c,p){return e(),o("div",null,a)}var m=t(n,[["render",i]]);export{v as __pageData,m as default};
|