github.com/newrelic/newrelic-client-go@v1.1.0/pkg/nrdb/types.go (about) 1 // Code generated by tutone: DO NOT EDIT 2 package nrdb 3 4 import ( 5 "encoding/json" 6 "fmt" 7 8 "github.com/newrelic/newrelic-client-go/pkg/nrtime" 9 ) 10 11 // ChartFormatType - Represents all the format types available for static charts. 12 type ChartFormatType string 13 14 var ChartFormatTypeTypes = struct { 15 PDF ChartFormatType 16 PNG ChartFormatType 17 }{ 18 PDF: "PDF", 19 PNG: "PNG", 20 } 21 22 // ChartImageType - Represents all the visualization types available for static charts. 23 type ChartImageType string 24 25 var ChartImageTypeTypes = struct { 26 APDEX ChartImageType 27 AREA ChartImageType 28 BAR ChartImageType 29 BASELINE ChartImageType 30 BILLBOARD ChartImageType 31 BULLET ChartImageType 32 EVENT_FEED ChartImageType 33 FUNNEL ChartImageType 34 HEATMAP ChartImageType 35 HISTOGRAM ChartImageType 36 LINE ChartImageType 37 PIE ChartImageType 38 SCATTER ChartImageType 39 STACKED_HORIZONTAL_BAR ChartImageType 40 TABLE ChartImageType 41 VERTICAL_BAR ChartImageType 42 }{ 43 APDEX: "APDEX", 44 AREA: "AREA", 45 BAR: "BAR", 46 BASELINE: "BASELINE", 47 BILLBOARD: "BILLBOARD", 48 BULLET: "BULLET", 49 EVENT_FEED: "EVENT_FEED", 50 FUNNEL: "FUNNEL", 51 HEATMAP: "HEATMAP", 52 HISTOGRAM: "HISTOGRAM", 53 LINE: "LINE", 54 PIE: "PIE", 55 SCATTER: "SCATTER", 56 STACKED_HORIZONTAL_BAR: "STACKED_HORIZONTAL_BAR", 57 TABLE: "TABLE", 58 VERTICAL_BAR: "VERTICAL_BAR", 59 } 60 61 // EmbeddedChartType - Represents all the visualization types available for embedded charts. 62 type EmbeddedChartType string 63 64 var EmbeddedChartTypeTypes = struct { 65 APDEX EmbeddedChartType 66 AREA EmbeddedChartType 67 BAR EmbeddedChartType 68 BASELINE EmbeddedChartType 69 BILLBOARD EmbeddedChartType 70 BULLET EmbeddedChartType 71 EMPTY EmbeddedChartType 72 EVENT_FEED EmbeddedChartType 73 FUNNEL EmbeddedChartType 74 HEATMAP EmbeddedChartType 75 HISTOGRAM EmbeddedChartType 76 JSON EmbeddedChartType 77 LINE EmbeddedChartType 78 MARKDOWN EmbeddedChartType 79 PIE EmbeddedChartType 80 SCATTER EmbeddedChartType 81 STACKED_HORIZONTAL_BAR EmbeddedChartType 82 TABLE EmbeddedChartType 83 TRAFFIC_LIGHT EmbeddedChartType 84 VERTICAL_BAR EmbeddedChartType 85 }{ 86 APDEX: "APDEX", 87 AREA: "AREA", 88 BAR: "BAR", 89 BASELINE: "BASELINE", 90 BILLBOARD: "BILLBOARD", 91 BULLET: "BULLET", 92 EMPTY: "EMPTY", 93 EVENT_FEED: "EVENT_FEED", 94 FUNNEL: "FUNNEL", 95 HEATMAP: "HEATMAP", 96 HISTOGRAM: "HISTOGRAM", 97 JSON: "JSON", 98 LINE: "LINE", 99 MARKDOWN: "MARKDOWN", 100 PIE: "PIE", 101 SCATTER: "SCATTER", 102 STACKED_HORIZONTAL_BAR: "STACKED_HORIZONTAL_BAR", 103 TABLE: "TABLE", 104 TRAFFIC_LIGHT: "TRAFFIC_LIGHT", 105 VERTICAL_BAR: "VERTICAL_BAR", 106 } 107 108 // EventAttributeDefinition - A human-readable definition of an NRDB Event Type Attribute 109 type EventAttributeDefinition struct { 110 // This attribute's category 111 Category string `json:"category,omitempty"` 112 // A short description of this attribute 113 Definition string `json:"definition,omitempty"` 114 // The New Relic docs page for this attribute 115 DocumentationURL string `json:"documentationUrl,omitempty"` 116 // The human-friendly formatted name of the attribute 117 Label string `json:"label,omitempty"` 118 // The name of the attribute 119 Name string `json:"name,omitempty"` 120 } 121 122 // EventDefinition - A human-readable definition of an NRDB Event Type 123 type EventDefinition struct { 124 // A list of attribute definitions for this event type 125 Attributes []EventAttributeDefinition `json:"attributes,omitempty"` 126 // A short description of this event 127 Definition string `json:"definition,omitempty"` 128 // The human-friendly formatted name of the event 129 Label string `json:"label,omitempty"` 130 // The name of the event 131 Name string `json:"name,omitempty"` 132 } 133 134 // NRDBMetadata - An object containing metadata about the query and result. 135 type NRDBMetadata struct { 136 // A list of the event types that were queried. 137 EventTypes []string `json:"eventTypes,omitempty"` 138 // A list of facets that were queried. 139 Facets []string `json:"facets,omitempty"` 140 // Messages from NRDB included with the result. 141 Messages []string `json:"messages,omitempty"` 142 // Details about the query time window. 143 TimeWindow NRDBMetadataTimeWindow `json:"timeWindow,omitempty"` 144 } 145 146 // NRDBMetadataTimeWindow - An object representing details about a query's time window. 147 type NRDBMetadataTimeWindow struct { 148 // Timestamp marking the query begin time. 149 Begin nrtime.EpochMilliseconds `json:"begin,omitempty"` 150 // A clause representing the comparison time window. 151 CompareWith string `json:"compareWith,omitempty"` 152 // Timestamp marking the query end time. 153 End nrtime.EpochMilliseconds `json:"end,omitempty"` 154 // SINCE clause resulting from the query 155 Since string `json:"since,omitempty"` 156 // UNTIL clause resulting from the query 157 Until string `json:"until,omitempty"` 158 } 159 160 // NRDBResultContainer - A data structure that contains the results of the NRDB query along 161 // with other capabilities that enhance those results. 162 // 163 // Direct query results are available through `results`, `totalResult` and 164 // `otherResult`. The query you made is accessible through `nrql`, along with 165 // `metadata` about the query itself. Enhanced capabilities include 166 // `eventDefinitions`, `suggestedFacets` and more. 167 type NRDBResultContainer struct { 168 // In a `COMPARE WITH` query, the `currentResults` contain the results for the current comparison time window. 169 CurrentResults []NRDBResult `json:"currentResults,omitempty"` 170 // Generate a publicly sharable Embedded Chart URL for the NRQL query. 171 // 172 // For more details, see [our docs](https://docs.newrelic.com/docs/apis/graphql-api/tutorials/query-nrql-through-new-relic-graphql-api#embeddable-charts). 173 EmbeddedChartURL string `json:"embeddedChartUrl,omitempty"` 174 // Retrieve a list of event type definitions, providing descriptions 175 // of the event types returned by this query, as well as details 176 // of their attributes. 177 EventDefinitions []EventDefinition `json:"eventDefinitions,omitempty"` 178 // Metadata about the query and result. 179 Metadata NRDBMetadata `json:"metadata,omitempty"` 180 // The [NRQL](https://docs.newrelic.com/docs/insights/nrql-new-relic-query-language/nrql-resources/nrql-syntax-components-functions) query that was executed to yield these results. 181 NRQL NRQL `json:"nrql,omitempty"` 182 // In a `FACET` query, the `otherResult` contains the aggregates representing the events _not_ 183 // contained in an individual `results` facet 184 OtherResult NRDBResult `json:"otherResult,omitempty"` 185 // In a `COMPARE WITH` query, the `previousResults` contain the results for the previous comparison time window. 186 PreviousResults []NRDBResult `json:"previousResults,omitempty"` 187 // The query results. This is a flat list of objects who's structure matches the query submitted. 188 Results []NRDBResult `json:"results,omitempty"` 189 // Generate a publicly sharable static chart URL for the NRQL query. 190 StaticChartURL string `json:"staticChartUrl,omitempty"` 191 // Retrieve a list of suggested NRQL facets for this NRDB query, to be used with 192 // the `FACET` keyword in NRQL. 193 // 194 // Results are based on historical query behaviors. 195 // 196 // If the query already has a `FACET` clause, it will be ignored for the purposes 197 // of suggesting facets. 198 // 199 // For more details, see [our docs](https://docs.newrelic.com/docs/apis/graphql-api/tutorials/nerdgraph-graphiql-nrql-tutorial#suggest-facets). 200 SuggestedFacets []NRQLFacetSuggestion `json:"suggestedFacets,omitempty"` 201 // Suggested queries that could help explain an anomaly in your timeseries based on either statistical differences in the data or historical usage. 202 // 203 // If no `anomalyTimeWindow` is supplied, we will attempt to detect a spike in the NRQL results. If no spike is found, the suggested query results will be empty. 204 // 205 // Input NRQL must be a TIMESERIES query and must have exactly one result. 206 SuggestedQueries SuggestedNRQLQueryResponse `json:"suggestedQueries,omitempty"` 207 // In a `FACET` query, the `totalResult` contains the aggregates representing _all_ the events, 208 // whether or not they are contained in an individual `results` facet 209 TotalResult NRDBResult `json:"totalResult,omitempty"` 210 } 211 212 // NRQLFacetSuggestion - A suggested NRQL facet. Facet suggestions may be either a single attribute, or 213 // a list of attributes in the case of multi-attribute facet suggestions. 214 type NRQLFacetSuggestion struct { 215 // A list of attribute names comprising the suggested facet. 216 // 217 // Raw attribute names will be returned here. Attribute names may need to be 218 // backtick-quoted before inclusion in a NRQL query. 219 Attributes []string `json:"attributes,omitempty"` 220 // A modified version of the input NRQL, with a `FACET ...` clause appended. 221 // If the original NRQL had a `FACET` clause already, it will be replaced. 222 NRQL NRQL `json:"nrql,omitempty"` 223 } 224 225 // NRQLHistoricalQuery - An NRQL query executed in the past. 226 type NRQLHistoricalQuery struct { 227 // The Account ID queried. 228 AccountID int `json:"accountId,omitempty"` 229 // The NRQL query executed. 230 NRQL NRQL `json:"nrql,omitempty"` 231 // The time the query was executed. 232 Timestamp nrtime.EpochSeconds `json:"timestamp,omitempty"` 233 } 234 235 // SuggestedAnomalyBasedNRQLQuery - A query suggestion based on analysis of events within a specific anomalous time 236 // range vs. nearby events outside of that time range. 237 type SuggestedAnomalyBasedNRQLQuery struct { 238 // Information about the anomaly upon which this suggestion is based 239 Anomaly SuggestedNRQLQueryAnomaly `json:"anomaly"` 240 // The NRQL string to run for the suggested query 241 NRQL string `json:"nrql"` 242 // A human-readable title describing what the query shows 243 Title string `json:"title"` 244 } 245 246 func (x *SuggestedAnomalyBasedNRQLQuery) ImplementsSuggestedNRQLQuery() {} 247 248 // SuggestedHistoryBasedNRQLQuery - A query suggestion based on historical query patterns. 249 type SuggestedHistoryBasedNRQLQuery struct { 250 // The NRQL string to run for the suggested query 251 NRQL string `json:"nrql"` 252 // A human-readable title describing what the query shows 253 Title string `json:"title"` 254 } 255 256 func (x *SuggestedHistoryBasedNRQLQuery) ImplementsSuggestedNRQLQuery() {} 257 258 // SuggestedNRQLQuery - Interface type representing a query suggestion. 259 type SuggestedNRQLQuery struct { 260 // The NRQL string to run for the suggested query 261 NRQL string `json:"nrql"` 262 // A human-readable title describing what the query shows 263 Title string `json:"title"` 264 } 265 266 func (x *SuggestedNRQLQuery) ImplementsSuggestedNRQLQuery() {} 267 268 // SuggestedNRQLQueryAnomaly - Information about the anomaly upon which this analysis was based. 269 type SuggestedNRQLQueryAnomaly struct { 270 // The approximate time window of the anomalous region 271 TimeWindow TimeWindow `json:"timeWindow"` 272 } 273 274 // SuggestedNRQLQueryResponse - A result type encapsulating suggested queries 275 type SuggestedNRQLQueryResponse struct { 276 // List of suggested queries. 277 Suggestions []SuggestedNRQLQueryInterface `json:"suggestions"` 278 } 279 280 // special 281 func (x *SuggestedNRQLQueryResponse) UnmarshalJSON(b []byte) error { 282 var objMap map[string]*json.RawMessage 283 err := json.Unmarshal(b, &objMap) 284 if err != nil { 285 return err 286 } 287 288 for k, v := range objMap { 289 if v == nil { 290 continue 291 } 292 293 switch k { 294 case "suggestions": 295 if v == nil { 296 continue 297 } 298 var rawMessageSuggestions []*json.RawMessage 299 err = json.Unmarshal(*v, &rawMessageSuggestions) 300 if err != nil { 301 return err 302 } 303 304 for _, m := range rawMessageSuggestions { 305 xxx, err := UnmarshalSuggestedNRQLQueryInterface(*m) 306 if err != nil { 307 return err 308 } 309 310 if xxx != nil { 311 x.Suggestions = append(x.Suggestions, *xxx) 312 } 313 } 314 } 315 } 316 317 return nil 318 } 319 320 // TimeWindow - Represents a time window. 321 type TimeWindow struct { 322 // The end time of the time window the number of milliseconds since the Unix epoch. 323 EndTime nrtime.EpochMilliseconds `json:"endTime,omitempty"` 324 // The start time of the time window the number of milliseconds since the Unix epoch. 325 StartTime nrtime.EpochMilliseconds `json:"startTime,omitempty"` 326 } 327 328 // NRDBResult - This scalar represents a NRDB Result. It is a `Map` of `String` keys to values. 329 // 330 // The shape of these objects reflect the query used to generate them, the contents 331 // of the objects is not part of the GraphQL schema. 332 type NRDBResult map[string]interface{} 333 334 // NRQL - This scalar represents a NRQL query string. 335 // 336 // See the [NRQL Docs](https://docs.newrelic.com/docs/insights/nrql-new-relic-query-language/nrql-resources/nrql-syntax-components-functions) for more information about NRQL syntax. 337 type NRQL string 338 339 // SuggestedNRQLQuery - Interface type representing a query suggestion. 340 type SuggestedNRQLQueryInterface interface { 341 ImplementsSuggestedNRQLQuery() 342 } 343 344 // UnmarshalSuggestedNRQLQueryInterface unmarshals the interface into the correct type 345 // based on __typename provided by GraphQL 346 func UnmarshalSuggestedNRQLQueryInterface(b []byte) (*SuggestedNRQLQueryInterface, error) { 347 var err error 348 349 var rawMessageSuggestedNRQLQuery map[string]*json.RawMessage 350 err = json.Unmarshal(b, &rawMessageSuggestedNRQLQuery) 351 if err != nil { 352 return nil, err 353 } 354 355 // Nothing to unmarshal 356 if len(rawMessageSuggestedNRQLQuery) < 1 { 357 return nil, nil 358 } 359 360 var typeName string 361 362 if rawTypeName, ok := rawMessageSuggestedNRQLQuery["__typename"]; ok { 363 err = json.Unmarshal(*rawTypeName, &typeName) 364 if err != nil { 365 return nil, err 366 } 367 368 switch typeName { 369 case "SuggestedAnomalyBasedNrqlQuery": 370 var interfaceType SuggestedAnomalyBasedNRQLQuery 371 err = json.Unmarshal(b, &interfaceType) 372 if err != nil { 373 return nil, err 374 } 375 376 var xxx SuggestedNRQLQueryInterface = &interfaceType 377 378 return &xxx, nil 379 case "SuggestedHistoryBasedNrqlQuery": 380 var interfaceType SuggestedHistoryBasedNRQLQuery 381 err = json.Unmarshal(b, &interfaceType) 382 if err != nil { 383 return nil, err 384 } 385 386 var xxx SuggestedNRQLQueryInterface = &interfaceType 387 388 return &xxx, nil 389 } 390 } else { 391 keys := []string{} 392 for k := range rawMessageSuggestedNRQLQuery { 393 keys = append(keys, k) 394 } 395 return nil, fmt.Errorf("interface SuggestedNRQLQuery did not include a __typename field for inspection: %s", keys) 396 } 397 398 return nil, fmt.Errorf("interface SuggestedNRQLQuery was not matched against all PossibleTypes: %s", typeName) 399 }