github.com/MetalBlockchain/metalgo@v1.11.9/api/admin/service.md (about)

     1  ---
     2  tags: [AvalancheGo APIs]
     3  description: This page is an overview of the Admin API associated with AvalancheGo.
     4  sidebar_label: Admin API
     5  pagination_label: Admin API
     6  ---
     7  
     8  # Admin API
     9  
    10  This API can be used for measuring node health and debugging.
    11  
    12  :::info
    13  The Admin API is disabled by default for security reasons. To run a node with the Admin API
    14  enabled, use [config flag `--api-admin-enabled=true`](/nodes/configure/avalanchego-config-flags.md#--api-admin-enabled-boolean).
    15  
    16  This API set is for a specific node, it is unavailable on the [public server](/tooling/rpc-providers.md).
    17  
    18  :::
    19  
    20  ## Format
    21  
    22  This API uses the `json 2.0` RPC format. For details, see [here](/reference/standards/guides/issuing-api-calls.md).
    23  
    24  ## Endpoint
    25  
    26  ```text
    27  /ext/admin
    28  ```
    29  
    30  ## Methods
    31  
    32  ### `admin.alias`
    33  
    34  Assign an API endpoint an alias, a different endpoint for the API. The original endpoint will still
    35  work. This change only affects this node; other nodes will not know about this alias.
    36  
    37  **Signature:**
    38  
    39  ```text
    40  admin.alias({endpoint:string, alias:string}) -> {}
    41  ```
    42  
    43  - `endpoint` is the original endpoint of the API. `endpoint` should only include the part of the
    44    endpoint after `/ext/`.
    45  - The API being aliased can now be called at `ext/alias`.
    46  - `alias` can be at most 512 characters.
    47  
    48  **Example Call:**
    49  
    50  ```bash
    51  curl -X POST --data '{
    52      "jsonrpc":"2.0",
    53      "id"     :1,
    54      "method" :"admin.alias",
    55      "params": {
    56          "alias":"myAlias",
    57          "endpoint":"bc/X"
    58      }
    59  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
    60  ```
    61  
    62  **Example Response:**
    63  
    64  ```json
    65  {
    66    "jsonrpc": "2.0",
    67    "id": 1,
    68    "result": {}
    69  }
    70  ```
    71  
    72  Now, calls to the X-Chain can be made to either `/ext/bc/X` or, equivalently, to `/ext/myAlias`.
    73  
    74  ### `admin.aliasChain`
    75  
    76  Give a blockchain an alias, a different name that can be used any place the blockchain’s ID is used.
    77  
    78  :::note Aliasing a chain can also be done via the [Node API](/nodes/configure/avalanchego-config-flags.md#--chain-aliases-file-string).
    79  Note that the alias is set for each chain on each node individually. In a multi-node Subnet, the
    80  same alias should be configured on each node to use an alias across a Subnet successfully. Setting
    81  an alias for a chain on one node does not register that alias with other nodes automatically.
    82  
    83  :::
    84  
    85  **Signature:**
    86  
    87  ```text
    88  admin.aliasChain(
    89      {
    90          chain:string,
    91          alias:string
    92      }
    93  ) -> {}
    94  ```
    95  
    96  - `chain` is the blockchain’s ID.
    97  - `alias` can now be used in place of the blockchain’s ID (in API endpoints, for example.)
    98  
    99  **Example Call:**
   100  
   101  ```bash
   102  curl -X POST --data '{
   103      "jsonrpc":"2.0",
   104      "id"     :1,
   105      "method" :"admin.aliasChain",
   106      "params": {
   107          "chain":"sV6o671RtkGBcno1FiaDbVcFv2sG5aVXMZYzKdP4VQAWmJQnM",
   108          "alias":"myBlockchainAlias"
   109      }
   110  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   111  ```
   112  
   113  **Example Response:**
   114  
   115  ```json
   116  {
   117    "jsonrpc": "2.0",
   118    "id": 1,
   119    "result": {}
   120  }
   121  ```
   122  
   123  Now, instead of interacting with the blockchain whose ID is
   124  `sV6o671RtkGBcno1FiaDbVcFv2sG5aVXMZYzKdP4VQAWmJQnM` by making API calls to
   125  `/ext/bc/sV6o671RtkGBcno1FiaDbVcFv2sG5aVXMZYzKdP4VQAWmJQnM`, one can also make calls to
   126  `ext/bc/myBlockchainAlias`.
   127  
   128  ### `admin.getChainAliases`
   129  
   130  Returns the aliases of the chain
   131  
   132  **Signature:**
   133  
   134  ```text
   135  admin.getChainAliases(
   136      {
   137          chain:string
   138      }
   139  ) -> {aliases:string[]}
   140  ```
   141  
   142  - `chain` is the blockchain’s ID.
   143  
   144  **Example Call:**
   145  
   146  ```bash
   147  curl -X POST --data '{
   148      "jsonrpc":"2.0",
   149      "id"     :1,
   150      "method" :"admin.getChainAliases",
   151      "params": {
   152          "chain":"sV6o671RtkGBcno1FiaDbVcFv2sG5aVXMZYzKdP4VQAWmJQnM"
   153      }
   154  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   155  ```
   156  
   157  **Example Response:**
   158  
   159  ```json
   160  {
   161    "jsonrpc": "2.0",
   162    "result": {
   163      "aliases": [
   164        "X",
   165        "avm",
   166        "2eNy1mUFdmaxXNj1eQHUe7Np4gju9sJsEtWQ4MX3ToiNKuADed"
   167      ]
   168    },
   169    "id": 1
   170  }
   171  ```
   172  
   173  ### `admin.getLoggerLevel`
   174  
   175  Returns log and display levels of loggers.
   176  
   177  **Signature:**
   178  
   179  ```text
   180  admin.getLoggerLevel(
   181      {
   182          loggerName:string // optional
   183      }
   184  ) -> {
   185          loggerLevels: {
   186              loggerName: {
   187                      logLevel: string,
   188                      displayLevel: string
   189              }
   190          }
   191      }
   192  ```
   193  
   194  - `loggerName` is the name of the logger to be returned. This is an optional argument. If not
   195    specified, it returns all possible loggers.
   196  
   197  **Example Call:**
   198  
   199  ```bash
   200  curl -X POST --data '{
   201      "jsonrpc":"2.0",
   202      "id"     :1,
   203      "method" :"admin.getLoggerLevel",
   204      "params": {
   205          "loggerName": "C"
   206      }
   207  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   208  ```
   209  
   210  **Example Response:**
   211  
   212  ```json
   213  {
   214    "jsonrpc": "2.0",
   215    "result": {
   216      "loggerLevels": {
   217        "C": {
   218          "logLevel": "DEBUG",
   219          "displayLevel": "INFO"
   220        }
   221      }
   222    },
   223    "id": 1
   224  }
   225  ```
   226  
   227  ### `admin.loadVMs`
   228  
   229  Dynamically loads any virtual machines installed on the node as plugins. See
   230  [here](/build/vm/intro#installing-a-vm) for more information on how to install a
   231  virtual machine on a node.
   232  
   233  **Signature:**
   234  
   235  ```sh
   236  admin.loadVMs() -> {
   237      newVMs: map[string][]string
   238      failedVMs: map[string]string,
   239  }
   240  ```
   241  
   242  - `failedVMs` is only included in the response if at least one virtual machine fails to be loaded.
   243  
   244  **Example Call:**
   245  
   246  ```bash
   247  curl -X POST --data '{
   248      "jsonrpc":"2.0",
   249      "id"     :1,
   250      "method" :"admin.loadVMs",
   251      "params" :{}
   252  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   253  ```
   254  
   255  **Example Response:**
   256  
   257  ```json
   258  {
   259    "jsonrpc": "2.0",
   260    "result": {
   261      "newVMs": {
   262        "tGas3T58KzdjLHhBDMnH2TvrddhqTji5iZAMZ3RXs2NLpSnhH": ["foovm"]
   263      },
   264      "failedVMs": {
   265        "rXJsCSEYXg2TehWxCEEGj6JU2PWKTkd6cBdNLjoe2SpsKD9cy": "error message"
   266      }
   267    },
   268    "id": 1
   269  }
   270  ```
   271  
   272  ### `admin.lockProfile`
   273  
   274  Writes a profile of mutex statistics to `lock.profile`.
   275  
   276  **Signature:**
   277  
   278  ```text
   279  admin.lockProfile() -> {}
   280  ```
   281  
   282  **Example Call:**
   283  
   284  ```bash
   285  curl -X POST --data '{
   286      "jsonrpc":"2.0",
   287      "id"     :1,
   288      "method" :"admin.lockProfile",
   289      "params" :{}
   290  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   291  ```
   292  
   293  **Example Response:**
   294  
   295  ```json
   296  {
   297    "jsonrpc": "2.0",
   298    "id": 1,
   299    "result": {}
   300  }
   301  ```
   302  
   303  ### `admin.memoryProfile`
   304  
   305  Writes a memory profile of the to `mem.profile`.
   306  
   307  **Signature:**
   308  
   309  ```text
   310  admin.memoryProfile() -> {}
   311  ```
   312  
   313  **Example Call:**
   314  
   315  ```bash
   316  curl -X POST --data '{
   317      "jsonrpc":"2.0",
   318      "id"     :1,
   319      "method" :"admin.memoryProfile",
   320      "params" :{}
   321  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   322  ```
   323  
   324  **Example Response:**
   325  
   326  ```json
   327  {
   328    "jsonrpc": "2.0",
   329    "id": 1,
   330    "result": {}
   331  }
   332  ```
   333  
   334  ### `admin.setLoggerLevel`
   335  
   336  Sets log and display levels of loggers.
   337  
   338  **Signature:**
   339  
   340  ```text
   341  admin.setLoggerLevel(
   342      {
   343          loggerName: string, // optional
   344          logLevel: string, // optional
   345          displayLevel: string, // optional
   346      }
   347  ) -> {}
   348  ```
   349  
   350  - `loggerName` is the logger's name to be changed. This is an optional parameter. If not specified,
   351    it changes all possible loggers.
   352  - `logLevel` is the log level of written logs, can be omitted.
   353  - `displayLevel` is the log level of displayed logs, can be omitted.
   354  
   355  `logLevel` and `displayLevel` cannot be omitted at the same time.
   356  
   357  **Example Call:**
   358  
   359  ```bash
   360  curl -X POST --data '{
   361      "jsonrpc":"2.0",
   362      "id"     :1,
   363      "method" :"admin.setLoggerLevel",
   364      "params": {
   365          "loggerName": "C",
   366          "logLevel": "DEBUG",
   367          "displayLevel": "INFO"
   368      }
   369  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   370  ```
   371  
   372  **Example Response:**
   373  
   374  ```json
   375  {
   376    "jsonrpc": "2.0",
   377    "id": 1,
   378    "result": {}
   379  }
   380  ```
   381  
   382  ### `admin.startCPUProfiler`
   383  
   384  Start profiling the CPU utilization of the node. To stop, call `admin.stopCPUProfiler`. On stop,
   385  writes the profile to `cpu.profile`.
   386  
   387  **Signature:**
   388  
   389  ```text
   390  admin.startCPUProfiler() -> {}
   391  ```
   392  
   393  **Example Call:**
   394  
   395  ```bash
   396  curl -X POST --data '{
   397      "jsonrpc":"2.0",
   398      "id"     :1,
   399      "method" :"admin.startCPUProfiler",
   400      "params" :{}
   401  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   402  ```
   403  
   404  **Example Response:**
   405  
   406  ```json
   407  {
   408    "jsonrpc": "2.0",
   409    "id": 1,
   410    "result": {}
   411  }
   412  ```
   413  
   414  ### `admin.stopCPUProfiler`
   415  
   416  Stop the CPU profile that was previously started.
   417  
   418  **Signature:**
   419  
   420  ```text
   421  admin.stopCPUProfiler() -> {}
   422  ```
   423  
   424  **Example Call:**
   425  
   426  ```bash
   427  curl -X POST --data '{
   428      "jsonrpc":"2.0",
   429      "id"     :1,
   430      "method" :"admin.stopCPUProfiler"
   431  }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/admin
   432  ```
   433  
   434  **Example Response:**
   435  
   436  ```json
   437  {
   438    "jsonrpc": "2.0",
   439    "id": 1,
   440    "result": {}
   441  }
   442  ```