TrueSight API Documentation
OverviewAccountActionsAdministration
Alarms v1Alarms v2BatchingDashboards
DatasetsEventsExtended Metrics
GroupsHostgroupsMetersMetricsProduct
PluginsRelaysSourcesSource-TagsSynchronize Data
Tenants
Terms

POST/v1/hostgroups

Create a Hostgroup

System Hostgroups cannot be created

name

The name of the hostgroup

hostnames

The list of servers in the hostgroup, an empty array will match all of the hosts in your account

expression

An dynamic group expression (use either a list of groups or an express, we give higher priority to the expression)

Example request with a list of hostnames:

curl https://api.truesight.bmc.com/v1/hostgroups \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
{
   "name": "web-servers",
   "hostnames": [
      "web1",
      "web2"
   ]
}'

Example request with dynamic group expression:

curl https://api.truesight.bmc.com/v1/hostgroups \
-X POST \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
{
   "name": "web-servers",
   "expression": "{\"where\": \"'hostname' starts with 'web'\"}"
}'

Response:

[
   {
      "id": 8332,
      "name": "web-servers",
      "hostnames": [
         "web1",
         "web2"
      ],
      "system": false
   }
]

400 Format Error response (the expression is malformed JSON):

{
   "name": "Format Error",
   "code": "ERR_BAD_FORMAT",
   "status": 400,
   "message": "Hostgroup expression is malformed JSON: Unexpected token w"
}

400 SyntaxError response (the where clause text is malformed):

{
   "name": "SyntaxError",
   "code": "ERR_BAD_FORMAT",
   "status": 400,
   "message": "Expected \"with\", comment or whitespace but \"W\" found.",
   "expected": [
      {
         "type": "literal",
         "value": "with",
         "description": "\"with\""
      },
      {
         "type": "other",
         "description": "comment"
      },
      {
         "type": "other",
         "description": "whitespace"
      }
   ],
   "found": "w",
   "offset": 37,
   "line": 1,
   "column": 38
}