/api/search

This endpoint provides a basic means of searching OpenTSDB meta data. Lookups can be performed against the tsdb-meta table when enabled. Optionally, a search plugin can be installed to send and retreive information from an external search indexing service such as Elastic Search. It is up to each search plugin to implement various parts of this endpoint and return data in a consistent format. The type of object searched and returned depends on the endpoint chosen.

Note

If the plugin is not configured or enabled, endpoints other than /api/search/lookup will return an exception.

Search API Endpoints

Verbs

  • GET

  • POST

Requests

Parameters used by the search endpoint include:

Name

Data Type

Required

Description

Default

QS

RW

Example

query

String

Optional

The string based query to pass to the search engine. This will be parsed by the engine or plugin to perform the actual search. Allowable values depends on the plugin. Ignored for lookups.

query

name:sys.cpu.

limit

Integer

Optional

Limits the number of results returned per query so as not to override the TSD or search engine. Allowable values depends on the plugin. Ignored for lookups.

25

limit

100

startIndex

Integer

Optional

Used in combination with the limit value to page through results. Allowable values depends on the plugin. Ignored for lookups.

0

start_index

42

metric

String

Optional

The name of a metric or a wildcard for lookup queries

metric

tsd.hbase.rpcs

tags

Array

Optional

One or more key/value objects with tag names and/or tag values for lookup queries. See /api/search/lookup

tags

See /api/search/lookup

Example Request

Query String:

  1. http://localhost:4242/api/search/tsmeta?query=name:*&limit=3&start_index=0

POST:

  1. {
  2. "query": "name:*",
  3. "limit": 4,
  4. "startIndex": 5
  5. }

Response

Depending on the endpoint called, the output will change slightly. However common fields include:

Name

Data Type

Description

Example

type

String

The type of query submitted, i.e. the endpoint called. Will be one of the endpoints listed above.

TSMETA

query

String

The query string submitted. May be altered by the plugin

name:sys.cpu.*

limit

Integer

The maximum number of items returned in the result set. Note that the actual number returned may be less than the limit.

25

startIndex

Integer

The starting index for the current result set as provided in the query

0

metric

String

The metric used for the lookup

tags

Array

The list of tag pairs used for lookup queries. May be an empty list.

[ ]

time

Integer

The amount of time it took, in milliseconds, to complete the query

120

totalResults

Integer

The total number of results matched by the query

1024

results

Array

The result set. The format depends on the endpoint requested.

See Below

This endpoint will almost always return a 200 with content body. If the query doesn’t match any results, the results field will be an empty array and totalResults will be 0. If an error occurs, such as the plugin being disabled or not configured, an exception will be returned.

TSMETA Response

The TSMeta endpoint returns a list of matching TSMeta objects.

  1. {
  2. "type": "TSMETA",
  3. "query": "name:*",
  4. "metric": "*",
  5. "tags": [],
  6. "limit": 2,
  7. "time": 675,
  8. "results": [
  9. {
  10. "tsuid": "0000150000070010D0",
  11. "metric": {
  12. "uid": "000015",
  13. "type": "METRIC",
  14. "name": "app.apache.connections",
  15. "description": "",
  16. "notes": "",
  17. "created": 1362655264,
  18. "custom": null,
  19. "displayName": ""
  20. },
  21. "tags": [
  22. {
  23. "uid": "000007",
  24. "type": "TAGK",
  25. "name": "fqdn",
  26. "description": "",
  27. "notes": "",
  28. "created": 1362655264,
  29. "custom": null,
  30. "displayName": ""
  31. },
  32. {
  33. "uid": "0010D0",
  34. "type": "TAGV",
  35. "name": "web01.mysite.com",
  36. "description": "",
  37. "notes": "",
  38. "created": 1362720007,
  39. "custom": null,
  40. "displayName": ""
  41. }
  42. ],
  43. "description": "",
  44. "notes": "",
  45. "created": 1362740528,
  46. "units": "",
  47. "retention": 0,
  48. "max": 0,
  49. "min": 0,
  50. "displayName": "",
  51. "dataType": "",
  52. "lastReceived": 0,
  53. "totalDatapoints": 0
  54. },
  55. {
  56. "tsuid": "0000150000070010D5",
  57. "metric": {
  58. "uid": "000015",
  59. "type": "METRIC",
  60. "name": "app.apache.connections",
  61. "description": "",
  62. "notes": "",
  63. "created": 1362655264,
  64. "custom": null,
  65. "displayName": ""
  66. },
  67. "tags": [
  68. {
  69. "uid": "000007",
  70. "type": "TAGK",
  71. "name": "fqdn",
  72. "description": "",
  73. "notes": "",
  74. "created": 1362655264,
  75. "custom": null,
  76. "displayName": ""
  77. },
  78. {
  79. "uid": "0010D5",
  80. "type": "TAGV",
  81. "name": "web02.mysite.com",
  82. "description": "",
  83. "notes": "",
  84. "created": 1362720007,
  85. "custom": null,
  86. "displayName": ""
  87. }
  88. ],
  89. "description": "",
  90. "notes": "",
  91. "created": 1362882263,
  92. "units": "",
  93. "retention": 0,
  94. "max": 0,
  95. "min": 0,
  96. "displayName": "",
  97. "dataType": "",
  98. "lastReceived": 0,
  99. "totalDatapoints": 0
  100. }
  101. ],
  102. "startIndex": 0,
  103. "totalResults": 9688066
  104. }

TSMETA_SUMMARY Response

The TSMeta Summary endpoint returns just the basic information associated with a timeseries including the TSUID, the metric name and tags. The search is run against the same index as the TSMeta query but returns a subset of the data.

  1. {
  2. "type": "TSMETA_SUMMARY",
  3. "query": "name:*",
  4. "metric": "*",
  5. "tags": [],
  6. "limit": 3,
  7. "time": 565,
  8. "results": [
  9. {
  10. "tags": {
  11. "fqdn": "web01.mysite.com"
  12. },
  13. "metric": "app.apache.connections",
  14. "tsuid": "0000150000070010D0"
  15. },
  16. {
  17. "tags": {
  18. "fqdn": "web02.mysite.com"
  19. },
  20. "metric": "app.apache.connections",
  21. "tsuid": "0000150000070010D5"
  22. },
  23. {
  24. "tags": {
  25. "fqdn": "web03.mysite.com"
  26. },
  27. "metric": "app.apache.connections",
  28. "tsuid": "0000150000070010D6"
  29. }
  30. ],
  31. "startIndex": 0,
  32. "totalResults": 9688066
  33. }

TSUIDS Response

The TSUIDs endpoint returns a list of TSUIDS that match the query. The search is run against the same index as the TSMeta query but returns a subset of the data.

  1. {
  2. "type": "TSUIDS",
  3. "query": "name:*",
  4. "metric": "*",
  5. "tags": [],
  6. "limit": 3,
  7. "time": 517,
  8. "results": [
  9. "0000150000070010D0",
  10. "0000150000070010D5",
  11. "0000150000070010D6"
  12. ],
  13. "startIndex": 0,
  14. "totalResults": 9688066
  15. }

UIDMETA Response

The UIDMeta endpoint returns a list of UIDMeta objects that match the query.

  1. {
  2. "type": "UIDMETA",
  3. "query": "name:*",
  4. "metric": "*",
  5. "tags": [],
  6. "limit": 3,
  7. "time": 517,
  8. "results": [
  9. {
  10. "uid": "000007",
  11. "type": "TAGK",
  12. "name": "fqdn",
  13. "description": "",
  14. "notes": "",
  15. "created": 1362655264,
  16. "custom": null,
  17. "displayName": ""
  18. },
  19. {
  20. "uid": "0010D0",
  21. "type": "TAGV",
  22. "name": "web01.mysite.com",
  23. "description": "",
  24. "notes": "",
  25. "created": 1362720007,
  26. "custom": null,
  27. "displayName": ""
  28. },
  29. {
  30. "uid": "0010D5",
  31. "type": "TAGV",
  32. "name": "web02.mysite.com",
  33. "description": "",
  34. "notes": "",
  35. "created": 1362720007,
  36. "custom": null,
  37. "displayName": ""
  38. }
  39. ],
  40. "startIndex": 0,
  41. "totalResults": 9688066
  42. }

Annotation Response

The Annotation endpoint returns a list of Annotation objects that match the query.

  1. {
  2. "type": "ANNOTATION",
  3. "query": "description:*",
  4. "metric": "*",
  5. "tags": [],
  6. "limit": 25,
  7. "time": 80,
  8. "results": [
  9. {
  10. "tsuid": "000001000001000001",
  11. "description": "Testing Annotations",
  12. "notes": "These would be details about the event, the description is just a summary",
  13. "custom": {
  14. "owner": "jdoe",
  15. "dept": "ops"
  16. },
  17. "endTime": 0,
  18. "startTime": 1369141261
  19. }
  20. ],
  21. "startIndex": 0,
  22. "totalResults": 1
  23. }