|
| 1 | +[role="xpack"] |
| 2 | +[[apm-api]] |
| 3 | +== API |
| 4 | + |
| 5 | +Some APM app features are provided via a REST API: |
| 6 | + |
| 7 | +* <<agent-config-api>> |
| 8 | + |
| 9 | +TIP: Kibana provides additional <<api,REST APIs>>, |
| 10 | +and general information on <<using-api,how to use APIs>>. |
| 11 | + |
| 12 | +//// |
| 13 | +******************************************************* |
| 14 | +//// |
| 15 | + |
| 16 | +[[agent-config-api]] |
| 17 | +=== Agent Configuration API |
| 18 | + |
| 19 | +The Agent configuration API allows you to fine-tune your APM agent configuration, |
| 20 | +without needing to redeploy your application. |
| 21 | + |
| 22 | +The following Agent configuration APIs are available: |
| 23 | + |
| 24 | +* <<apm-update-config>> to create or update an Agent configuration |
| 25 | +* <<apm-delete-config>> to delete an Agent configuration. |
| 26 | +* <<apm-list-config>> to list all Agent configurations. |
| 27 | +* <<apm-search-config>> to search for an Agent configuration. |
| 28 | + |
| 29 | +//// |
| 30 | +******************************************************* |
| 31 | +//// |
| 32 | + |
| 33 | +[[apm-update-config]] |
| 34 | +==== Create or update configuration |
| 35 | + |
| 36 | +[[apm-update-config-req]] |
| 37 | +===== Request |
| 38 | + |
| 39 | +`PUT /api/apm/settings/agent-configuration` |
| 40 | + |
| 41 | +[[apm-update-config-req-body]] |
| 42 | +===== Request body |
| 43 | + |
| 44 | +`service`:: |
| 45 | +(required, object) Service identifying the configuration to create or update. |
| 46 | + |
| 47 | +`name` ::: |
| 48 | + (required, string) Name of service |
| 49 | + |
| 50 | +`environment` ::: |
| 51 | + (optional, string) Environment of service |
| 52 | + |
| 53 | +`settings`:: |
| 54 | +(required) Key/value object with settings and their corresponding value. |
| 55 | + |
| 56 | +`agent_name`:: |
| 57 | +(optional) The agent name is used by the UI to determine which settings to display. |
| 58 | + |
| 59 | + |
| 60 | +[[apm-update-config-example]] |
| 61 | +===== Example |
| 62 | + |
| 63 | +[source,console] |
| 64 | +-------------------------------------------------- |
| 65 | +PUT /api/apm/settings/agent-configuration |
| 66 | +{ |
| 67 | + "service" : { |
| 68 | + "name" : "frontend", |
| 69 | + "environment" : "production" |
| 70 | + }, |
| 71 | + "settings" : { |
| 72 | + "transaction_sample_rate" : 0.4, |
| 73 | + "capture_body" : "off", |
| 74 | + "transaction_max_spans" : 500 |
| 75 | + }, |
| 76 | + "agent_name": "nodejs" |
| 77 | +} |
| 78 | +-------------------------------------------------- |
| 79 | + |
| 80 | +//// |
| 81 | +******************************************************* |
| 82 | +//// |
| 83 | + |
| 84 | + |
| 85 | +[[apm-delete-config]] |
| 86 | +==== Delete configuration |
| 87 | + |
| 88 | +[[apm-delete-config-req]] |
| 89 | +===== Request |
| 90 | + |
| 91 | +`DELETE /api/apm/settings/agent-configuration` |
| 92 | + |
| 93 | +[[apm-delete-config-req-body]] |
| 94 | +===== Request body |
| 95 | +`service`:: |
| 96 | +(required, object) Service identifying the configuration to delete |
| 97 | + |
| 98 | +`name` ::: |
| 99 | + (required, string) Name of service |
| 100 | + |
| 101 | +`environment` ::: |
| 102 | + (optional, string) Environment of service |
| 103 | + |
| 104 | + |
| 105 | +[[apm-delete-config-example]] |
| 106 | +===== Example |
| 107 | + |
| 108 | +[source,console] |
| 109 | +-------------------------------------------------- |
| 110 | +DELETE /api/apm/settings/agent-configuration |
| 111 | +{ |
| 112 | + "service" : { |
| 113 | + "name" : "frontend", |
| 114 | + "environment": "production" |
| 115 | + } |
| 116 | +} |
| 117 | +-------------------------------------------------- |
| 118 | + |
| 119 | +//// |
| 120 | +******************************************************* |
| 121 | +//// |
| 122 | + |
| 123 | + |
| 124 | +[[apm-list-config]] |
| 125 | +==== List configuration |
| 126 | + |
| 127 | + |
| 128 | +[[apm-list-config-req]] |
| 129 | +===== Request |
| 130 | + |
| 131 | +`GET /api/apm/settings/agent-configuration` |
| 132 | + |
| 133 | +[[apm-list-config-body]] |
| 134 | +===== Response body |
| 135 | + |
| 136 | +[source,js] |
| 137 | +-------------------------------------------------- |
| 138 | +[ |
| 139 | + { |
| 140 | + "agent_name": "go", |
| 141 | + "service": { |
| 142 | + "name": "opbeans-go", |
| 143 | + "environment": "production" |
| 144 | + }, |
| 145 | + "settings": { |
| 146 | + "transaction_sample_rate": 1, |
| 147 | + "capture_body": "off", |
| 148 | + "transaction_max_spans": 200 |
| 149 | + }, |
| 150 | + "@timestamp": 1581934104843, |
| 151 | + "applied_by_agent": false, |
| 152 | + "etag": "1e58c178efeebae15c25c539da740d21dee422fc" |
| 153 | + }, |
| 154 | + { |
| 155 | + "agent_name": "go", |
| 156 | + "service": { |
| 157 | + "name": "opbeans-go" |
| 158 | + }, |
| 159 | + "settings": { |
| 160 | + "transaction_sample_rate": 1, |
| 161 | + "capture_body": "off", |
| 162 | + "transaction_max_spans": 300 |
| 163 | + }, |
| 164 | + "@timestamp": 1581934111727, |
| 165 | + "applied_by_agent": false, |
| 166 | + "etag": "3eed916d3db434d9fb7f039daa681c7a04539a64" |
| 167 | + }, |
| 168 | + { |
| 169 | + "agent_name": "nodejs", |
| 170 | + "service": { |
| 171 | + "name": "frontend" |
| 172 | + }, |
| 173 | + "settings": { |
| 174 | + "transaction_sample_rate": 1, |
| 175 | + }, |
| 176 | + "@timestamp": 1582031336265, |
| 177 | + "applied_by_agent": false, |
| 178 | + "etag": "5080ed25785b7b19f32713681e79f46996801a5b" |
| 179 | + } |
| 180 | +] |
| 181 | +-------------------------------------------------- |
| 182 | + |
| 183 | +[[apm-list-config-example]] |
| 184 | +===== Example |
| 185 | + |
| 186 | +[source,console] |
| 187 | +-------------------------------------------------- |
| 188 | +GET /api/apm/settings/agent-configuration |
| 189 | +-------------------------------------------------- |
| 190 | + |
| 191 | +//// |
| 192 | +******************************************************* |
| 193 | +//// |
| 194 | + |
| 195 | + |
| 196 | +[[apm-search-config]] |
| 197 | +==== Search configuration |
| 198 | + |
| 199 | +[[apm-search-config-req]] |
| 200 | +===== Request |
| 201 | + |
| 202 | +`POST /api/apm/settings/agent-configuration/search` |
| 203 | + |
| 204 | +[[apm-search-config-req-body]] |
| 205 | +===== Request body |
| 206 | + |
| 207 | +`service`:: |
| 208 | +(required, object) Service identifying the configuration. |
| 209 | + |
| 210 | +`name` ::: |
| 211 | + (required, string) Name of service |
| 212 | + |
| 213 | +`environment` ::: |
| 214 | + (optional, string) Environment of service |
| 215 | + |
| 216 | +`etag`:: |
| 217 | +(required) etag is sent by the agent to indicate the etag of the last successfully applied configuration. If the etag matches an existing configuration its `applied_by_agent` property will be set to `true`. Every time a configuration is edited `applied_by_agent` is reset to `false`. |
| 218 | + |
| 219 | +[[apm-search-config-body]] |
| 220 | +===== Response body |
| 221 | + |
| 222 | +[source,js] |
| 223 | +-------------------------------------------------- |
| 224 | +{ |
| 225 | + "_index": ".apm-agent-configuration", |
| 226 | + "_id": "CIaqXXABmQCdPphWj8EJ", |
| 227 | + "_score": 2, |
| 228 | + "_source": { |
| 229 | + "agent_name": "nodejs", |
| 230 | + "service": { |
| 231 | + "name": "frontend" |
| 232 | + }, |
| 233 | + "settings": { |
| 234 | + "transaction_sample_rate": 1, |
| 235 | + }, |
| 236 | + "@timestamp": 1582031336265, |
| 237 | + "applied_by_agent": false, |
| 238 | + "etag": "5080ed25785b7b19f32713681e79f46996801a5b" |
| 239 | + } |
| 240 | +} |
| 241 | +-------------------------------------------------- |
| 242 | + |
| 243 | +[[apm-search-config-example]] |
| 244 | +===== Example |
| 245 | + |
| 246 | +[source,console] |
| 247 | +-------------------------------------------------- |
| 248 | +POST /api/apm/settings/agent-configuration/search |
| 249 | +{ |
| 250 | + "etag" : "1e58c178efeebae15c25c539da740d21dee422fc", |
| 251 | + "service" : { |
| 252 | + "name" : "frontend", |
| 253 | + "environment": "production" |
| 254 | + } |
| 255 | +} |
| 256 | +-------------------------------------------------- |
| 257 | + |
| 258 | +//// |
| 259 | +******************************************************* |
| 260 | +//// |
0 commit comments