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AAgB9B,EAAQ3B,MAAMC,GAAMA,EAAErI,QAAUgG,IAWtD,OAVIA,IAAS6F,IACX9B,EAAU,IACLA,EACH,CACE/J,MAAOgG,EACPjG,MAAOiG,MAMX,SAAC,EAAA8F,eAAD,WACE,SAAC,EAAAvB,YAAD,CAAaxK,MAAM,OAAOyK,MAAM,EAAMC,WAnS3B,GAmSX,UACE,SAAC,EAAApJ,OAAD,CACEC,kBAAgB,EAChBE,QAASuI,EACT/J,MAAO6L,GAAiB,GACxBnL,SAAUkC,KAAKmJ,gBACf/J,kBAAkB,EAClB2I,uBAAuB,EACvBC,YAAY,gBACZC,aAAa,EACb5I,kBAAoBC,GAAmB,WAAUA,UAO3D8J,SACE,MAAMvL,EAAQ,OAAH,UACNjB,EACAoD,KAAKkF,MAAMrH,OAGhB,OACE,iCACE,SAAC,EAAAqL,eAAD,WACE,SAAC,EAAAvB,YAAD,CAAaxK,MAAM,aAAayK,MAAM,EAAMC,WA7TnC,GA6TT,UACE,SAAC,EAAApJ,OAAD,CACEC,kBAAgB,EAChBE,QAASoB,KAAKqJ,WACdjM,MAAO4C,KAAKqJ,WAAW7D,MAAMjC,GAAMA,EAAEnG,QAAUS,EAAMf,aAAckD,KAAKqJ,WAAW,GACnFvL,SAAUkC,KAAKsJ,wBAIpBzL,EAAMf,YAAcH,EAAiBiF,kBAAoB5B,KAAKuH,0BAC9D1J,EAAMf,YAAcH,EAAiB0G,MAAQrD,KAAKgJ,4BClVpD,MAAMO,EAAS,IAAIC,EAAAA,iBAAkD7J,GAAmB8J,eAC7FvJ","sources":["webpack://grafana/./public/app/plugins/datasource/grafana/types.ts","webpack://grafana/./public/app/plugins/datasource/grafana/components/AnnotationQueryEditor.tsx","webpack://grafana/./public/app/plugins/datasource/grafana/datasource.ts","webpack://grafana/./public/app/plugins/datasource/grafana/components/QueryEditor.tsx","webpack://grafana/./public/app/plugins/datasource/grafana/module.ts"],"sourcesContent":["import { DataQuery } from '@grafana/data';\nimport { LiveDataFilter } from '@grafana/runtime';\n\n//----------------------------------------------\n// Query\n//----------------------------------------------\n\nexport enum GrafanaQueryType {\n LiveMeasurements = 'measurements',\n Annotations = 'annotations',\n\n // backend\n RandomWalk = 'randomWalk',\n List = 'list',\n Read = 'read',\n}\n\nexport interface GrafanaQuery extends DataQuery {\n queryType: GrafanaQueryType; // RandomWalk by default\n channel?: string;\n filter?: LiveDataFilter;\n buffer?: number;\n path?: string; // for list and read\n}\n\nexport const defaultQuery: GrafanaQuery = {\n refId: 'A',\n queryType: GrafanaQueryType.RandomWalk,\n};\n\n//----------------------------------------------\n// Annotations\n//----------------------------------------------\n\nexport enum GrafanaAnnotationType {\n Dashboard = 'dashboard',\n Tags = 'tags',\n}\n\nexport interface GrafanaAnnotationQuery extends GrafanaQuery {\n type: GrafanaAnnotationType; // tags\n limit: number; // 100\n tags?: string[];\n matchAny?: boolean; // By default Grafana only shows annotations that match all tags in the query. Enabling this returns annotations that match any of the tags in the query.\n}\n","import React from 'react';\nimport { SelectableValue } from '@grafana/data';\nimport { Field, FieldSet, Select, Switch } from '@grafana/ui';\nimport { css } from '@emotion/css';\n\nimport { TagFilter } from 'app/core/components/TagFilter/TagFilter';\nimport { GrafanaAnnotationQuery, GrafanaAnnotationType, GrafanaQuery } from '../types';\nimport { getAnnotationTags } from 'app/features/annotations/api';\n\nconst matchTooltipContent = 'Enabling this returns annotations that match any of the tags specified below';\n\nconst tagsTooltipContent = (\n
Specify a list of tags to match. To specify a key and value tag use `key:value` syntax.
\n);\n\nconst annotationTypes = [\n {\n label: 'Dashboard',\n value: GrafanaAnnotationType.Dashboard,\n description: 'Query for events created on this dashboard and show them in the panels where they where created',\n },\n {\n label: 'Tags',\n value: GrafanaAnnotationType.Tags,\n description: 'This will fetch any annotation events that match the tags filter',\n },\n];\n\nconst limitOptions = [10, 50, 100, 200, 300, 500, 1000, 2000].map((limit) => ({\n label: String(limit),\n value: limit,\n}));\n\ninterface Props {\n query: GrafanaQuery;\n onChange: (newValue: GrafanaAnnotationQuery) => void;\n}\n\nexport default function AnnotationQueryEditor({ query, onChange }: Props) {\n const annotationQuery = query as GrafanaAnnotationQuery;\n const { limit, matchAny, tags, type } = annotationQuery;\n const styles = getStyles();\n\n const onFilterByChange = (newValue: SelectableValue) =>\n onChange({\n ...annotationQuery,\n type: newValue.value!,\n });\n\n const onMaxLimitChange = (newValue: SelectableValue) =>\n onChange({\n ...annotationQuery,\n limit: newValue.value!,\n });\n\n const onMatchAnyChange = (newValue: React.ChangeEvent) =>\n onChange({\n ...annotationQuery,\n matchAny: newValue.target.checked,\n });\n\n const onTagsChange = (tags: string[]) =>\n onChange({\n ...annotationQuery,\n tags,\n });\n\n const onFormatCreateLabel = (input: string) => `Use custom value: ${input}`;\n\n return (\n
\n \n \n \n \n \n \n {type === GrafanaAnnotationType.Tags && (\n <>\n \n \n \n \n \n \n \n )}\n
\n );\n}\n\nconst getStyles = () => {\n return {\n container: css`\n max-width: 600px;\n `,\n };\n};\n","import { from, merge, Observable, of } from 'rxjs';\nimport {\n DataSourceWithBackend,\n getBackendSrv,\n getGrafanaLiveSrv,\n getTemplateSrv,\n StreamingFrameOptions,\n} from '@grafana/runtime';\nimport {\n AnnotationQuery,\n AnnotationQueryRequest,\n DataFrameView,\n DataQueryRequest,\n DataQueryResponse,\n DataSourceInstanceSettings,\n DataSourceRef,\n isValidLiveChannelAddress,\n MutableDataFrame,\n parseLiveChannelAddress,\n toDataFrame,\n} from '@grafana/data';\n\nimport { GrafanaAnnotationQuery, GrafanaAnnotationType, GrafanaQuery, GrafanaQueryType } from './types';\nimport AnnotationQueryEditor from './components/AnnotationQueryEditor';\nimport { getDashboardSrv } from '../../../features/dashboard/services/DashboardSrv';\nimport { isString } from 'lodash';\nimport { migrateDatasourceNameToRef } from 'app/features/dashboard/state/DashboardMigrator';\nimport { map } from 'rxjs/operators';\n\nlet counter = 100;\n\nexport class GrafanaDatasource extends DataSourceWithBackend {\n constructor(instanceSettings: DataSourceInstanceSettings) {\n super(instanceSettings);\n this.annotations = {\n QueryEditor: AnnotationQueryEditor,\n prepareAnnotation(json: any): AnnotationQuery {\n // Previously, these properties lived outside of target\n // This should handle migrating them\n json.target = json.target ?? {\n type: json.type ?? GrafanaAnnotationType.Dashboard,\n limit: json.limit ?? 100,\n tags: json.tags ?? [],\n matchAny: json.matchAny ?? false,\n }; // using spread syntax caused an infinite loop in StandardAnnotationQueryEditor\n return json;\n },\n prepareQuery(anno: AnnotationQuery): GrafanaQuery {\n let datasource: DataSourceRef | undefined | null = undefined;\n if (isString(anno.datasource)) {\n const ref = migrateDatasourceNameToRef(anno.datasource);\n if (ref) {\n datasource = ref;\n }\n } else {\n datasource = anno.datasource as DataSourceRef;\n }\n\n return { ...anno, refId: anno.name, queryType: GrafanaQueryType.Annotations, datasource };\n },\n };\n }\n\n query(request: DataQueryRequest): Observable {\n const results: Array> = [];\n const targets: GrafanaQuery[] = [];\n const templateSrv = getTemplateSrv();\n for (const target of request.targets) {\n if (target.queryType === GrafanaQueryType.Annotations) {\n return from(\n this.getAnnotations({\n range: request.range,\n rangeRaw: request.range.raw,\n annotation: target as unknown as AnnotationQuery,\n dashboard: getDashboardSrv().getCurrent(),\n })\n );\n }\n if (target.hide) {\n continue;\n }\n if (target.queryType === GrafanaQueryType.LiveMeasurements) {\n let channel = templateSrv.replace(target.channel, request.scopedVars);\n const { filter } = target;\n\n // Help migrate pre-release channel paths saved in dashboards\n // NOTE: this should be removed before V8 is released\n if (channel && channel.startsWith('telegraf/')) {\n channel = 'stream/' + channel;\n target.channel = channel; // mutate the current query object so it is saved with `stream/` prefix\n }\n\n const addr = parseLiveChannelAddress(channel);\n if (!isValidLiveChannelAddress(addr)) {\n continue;\n }\n const buffer: Partial = {\n maxLength: request.maxDataPoints ?? 500,\n };\n if (target.buffer) {\n buffer.maxDelta = target.buffer;\n buffer.maxLength = buffer.maxLength! * 2; //??\n } else if (request.rangeRaw?.to === 'now') {\n buffer.maxDelta = request.range.to.valueOf() - request.range.from.valueOf();\n }\n\n results.push(\n getGrafanaLiveSrv().getDataStream({\n key: `${request.requestId}.${counter++}`,\n addr: addr!,\n filter,\n buffer,\n })\n );\n } else {\n if (!target.queryType) {\n target.queryType = GrafanaQueryType.RandomWalk;\n }\n targets.push(target);\n }\n }\n\n if (targets.length) {\n results.push(\n super.query({\n ...request,\n targets,\n })\n );\n }\n\n if (results.length) {\n // With a single query just return the results\n if (results.length === 1) {\n return results[0];\n }\n return merge(...results);\n }\n return of(); // nothing\n }\n\n listFiles(path: string): Observable> {\n return this.query({\n targets: [\n {\n refId: 'A',\n queryType: GrafanaQueryType.List,\n path,\n },\n ],\n } as any).pipe(\n map((v) => {\n const frame = v.data[0] ?? new MutableDataFrame();\n return new DataFrameView(frame);\n })\n );\n }\n\n metricFindQuery(options: any) {\n return Promise.resolve([]);\n }\n\n async getAnnotations(options: AnnotationQueryRequest): Promise {\n const templateSrv = getTemplateSrv();\n const annotation = options.annotation as unknown as AnnotationQuery;\n const target = annotation.target!;\n const params: any = {\n from: options.range.from.valueOf(),\n to: options.range.to.valueOf(),\n limit: target.limit,\n tags: target.tags,\n matchAny: target.matchAny,\n };\n\n if (target.type === GrafanaAnnotationType.Dashboard) {\n // if no dashboard id yet return\n if (!options.dashboard.id) {\n return Promise.resolve({ data: [] });\n }\n // filter by dashboard id\n params.dashboardId = options.dashboard.id;\n // remove tags filter if any\n delete params.tags;\n } else {\n // require at least one tag\n if (!Array.isArray(target.tags) || target.tags.length === 0) {\n return Promise.resolve({ data: [] });\n }\n const delimiter = '__delimiter__';\n const tags = [];\n for (const t of params.tags) {\n const renderedValues = templateSrv.replace(t, {}, (value: any) => {\n if (typeof value === 'string') {\n return value;\n }\n\n return value.join(delimiter);\n });\n for (const tt of renderedValues.split(delimiter)) {\n tags.push(tt);\n }\n }\n params.tags = tags;\n }\n\n const annotations = await getBackendSrv().get(\n '/api/annotations',\n params,\n `grafana-data-source-annotations-${annotation.name}-${options.dashboard?.id}`\n );\n return { data: [toDataFrame(annotations)] };\n }\n\n testDatasource() {\n return Promise.resolve();\n }\n}\n\nexport interface FileElement {\n name: string;\n ['media-type']: string;\n}\n","import React, { PureComponent } from 'react';\nimport { InlineField, Select, Alert, Input, InlineFieldRow } from '@grafana/ui';\nimport {\n QueryEditorProps,\n SelectableValue,\n dataFrameFromJSON,\n rangeUtil,\n DataQueryRequest,\n DataFrame,\n} from '@grafana/data';\nimport { GrafanaDatasource } from '../datasource';\nimport { defaultQuery, GrafanaQuery, GrafanaQueryType } from '../types';\nimport { getBackendSrv, getDataSourceSrv } from '@grafana/runtime';\n\ntype Props = QueryEditorProps;\n\nconst labelWidth = 12;\n\ninterface State {\n channels: Array>;\n channelFields: Record>>;\n folders?: Array>;\n}\n\nexport class QueryEditor extends PureComponent {\n state: State = { channels: [], channelFields: {} };\n\n queryTypes: Array> = [\n {\n label: 'Random Walk',\n value: GrafanaQueryType.RandomWalk,\n description: 'Random signal within the selected time range',\n },\n {\n label: 'Live Measurements',\n value: GrafanaQueryType.LiveMeasurements,\n description: 'Stream real-time measurements from Grafana',\n },\n {\n label: 'List public files',\n value: GrafanaQueryType.List,\n description: 'Show directory listings for public resources',\n },\n ];\n\n loadChannelInfo() {\n getBackendSrv()\n .fetch({ url: 'api/live/list' })\n .subscribe({\n next: (v: any) => {\n const channelInfo = v.data?.channels as any[];\n if (channelInfo?.length) {\n const channelFields: Record>> = {};\n const channels: Array> = channelInfo.map((c) => {\n if (c.data) {\n const distinctFields = new Set();\n const frame = dataFrameFromJSON(c.data);\n for (const f of frame.fields) {\n distinctFields.add(f.name);\n }\n channelFields[c.channel] = Array.from(distinctFields).map((n) => ({\n value: n,\n label: n,\n }));\n }\n return {\n value: c.channel,\n label: c.channel + ' [' + c.minute_rate + ' msg/min]',\n };\n });\n\n this.setState({ channelFields, channels });\n }\n },\n });\n }\n\n loadFolderInfo() {\n const query: DataQueryRequest = {\n targets: [{ queryType: GrafanaQueryType.List, refId: 'A' }],\n } as any;\n\n getDataSourceSrv()\n .get('-- Grafana --')\n .then((ds) => {\n const gds = ds as GrafanaDatasource;\n gds.query(query).subscribe({\n next: (rsp) => {\n if (rsp.data.length) {\n const names = (rsp.data[0] as DataFrame).fields[0];\n const folders = names.values.toArray().map((v) => ({\n value: v,\n label: v,\n }));\n this.setState({ folders });\n }\n },\n });\n });\n }\n\n componentDidMount() {\n this.loadChannelInfo();\n }\n\n onQueryTypeChange = (sel: SelectableValue) => {\n const { onChange, query, onRunQuery } = this.props;\n onChange({ ...query, queryType: sel.value! });\n onRunQuery();\n\n // Reload the channel list\n this.loadChannelInfo();\n };\n\n onChannelChange = (sel: SelectableValue) => {\n const { onChange, query, onRunQuery } = this.props;\n onChange({ ...query, channel: sel?.value });\n onRunQuery();\n };\n\n onFieldNamesChange = (item: SelectableValue) => {\n const { onChange, query, onRunQuery } = this.props;\n let fields: string[] = [];\n if (Array.isArray(item)) {\n fields = item.map((v) => v.value);\n } else if (item.value) {\n fields = [item.value];\n }\n\n // When adding the first field, also add time (if it exists)\n if (fields.length === 1 && !query.filter?.fields?.length && query.channel) {\n const names = this.state.channelFields[query.channel] ?? [];\n const tf = names.find((f) => f.value === 'time' || f.value === 'Time');\n if (tf && tf.value && tf.value !== fields[0]) {\n fields = [tf.value, ...fields];\n }\n }\n\n onChange({\n ...query,\n filter: {\n ...query.filter,\n fields,\n },\n });\n onRunQuery();\n };\n\n checkAndUpdateBuffer = (txt: string) => {\n const { onChange, query, onRunQuery } = this.props;\n let buffer: number | undefined;\n if (txt) {\n try {\n buffer = rangeUtil.intervalToSeconds(txt) * 1000;\n } catch (err) {\n console.warn('ERROR', err);\n }\n }\n onChange({\n ...query,\n buffer,\n });\n onRunQuery();\n };\n\n handleEnterKey = (e: React.KeyboardEvent) => {\n if (e.key !== 'Enter') {\n return;\n }\n this.checkAndUpdateBuffer((e.target as any).value);\n };\n\n handleBlur = (e: React.FocusEvent) => {\n this.checkAndUpdateBuffer(e.target.value);\n };\n\n renderMeasurementsQuery() {\n let { channel, filter, buffer } = this.props.query;\n let { channels, channelFields } = this.state;\n let currentChannel = channels.find((c) => c.value === channel);\n if (channel && !currentChannel) {\n currentChannel = {\n value: channel,\n label: channel,\n description: `Connected to ${channel}`,\n };\n channels = [currentChannel, ...channels];\n }\n\n const distinctFields = new Set();\n const fields: Array> = channel ? channelFields[channel] ?? [] : [];\n // if (data && data.series?.length) {\n // for (const frame of data.series) {\n // for (const field of frame.fields) {\n // if (distinctFields.has(field.name) || !field.name) {\n // continue;\n // }\n // fields.push({\n // value: field.name,\n // label: field.name,\n // description: `(${getFrameDisplayName(frame)} / ${field.type})`,\n // });\n // distinctFields.add(field.name);\n // }\n // }\n // }\n if (filter?.fields) {\n for (const f of filter.fields) {\n if (!distinctFields.has(f)) {\n fields.push({\n value: f,\n label: `${f} (not loaded)`,\n description: `Configured, but not found in the query results`,\n });\n distinctFields.add(f);\n }\n }\n }\n\n let formattedTime = '';\n if (buffer) {\n formattedTime = rangeUtil.secondsToHms(buffer / 1000);\n }\n\n return (\n <>\n
\n \n `Connect to: ${input}`}\n />\n \n
\n {channel && (\n
\n \n `Field: ${input}`}\n isSearchable={true}\n isMulti={true}\n />\n \n \n \n \n
\n )}\n\n \n This supports real-time event streams in Grafana core. This feature is under heavy development. Expect the\n interfaces and structures to change as this becomes more production ready.\n \n \n );\n }\n\n onFolderChanged = (sel: SelectableValue) => {\n const { onChange, query, onRunQuery } = this.props;\n onChange({ ...query, path: sel?.value });\n onRunQuery();\n };\n\n renderListPublicFiles() {\n let { path } = this.props.query;\n let { folders } = this.state;\n if (!folders) {\n folders = [];\n this.loadFolderInfo();\n }\n const currentFolder = folders.find((f) => f.value === path);\n if (path && !currentFolder) {\n folders = [\n ...folders,\n {\n value: path,\n label: path,\n },\n ];\n }\n\n return (\n \n \n `Folder: ${input}`}\n />\n \n \n );\n }\n\n render() {\n const query = {\n ...defaultQuery,\n ...this.props.query,\n };\n\n return (\n <>\n \n \n v.value === query.queryType) || this.queryTypes[0]}\n onChange={this.onQueryTypeChange}\n />\n \n \n {query.queryType === GrafanaQueryType.LiveMeasurements && this.renderMeasurementsQuery()}\n {query.queryType === GrafanaQueryType.List && this.renderListPublicFiles()}\n \n );\n }\n}\n","import { DataSourcePlugin } from '@grafana/data';\nimport { GrafanaDatasource } from './datasource';\nimport { QueryEditor } from './components/QueryEditor';\nimport { GrafanaQuery } from './types';\n\nexport const plugin = new DataSourcePlugin(GrafanaDatasource).setQueryEditor(\n QueryEditor\n);\n"],"names":["GrafanaQueryType","defaultQuery","refId","queryType","RandomWalk","GrafanaAnnotationType","tagsTooltipContent","annotationTypes","label","value","Dashboard","description","Tags","limitOptions","map","limit","String","AnnotationQueryEditor","query","onChange","annotationQuery","matchAny","tags","type","styles","getStyles","FieldSet","className","container","Field","Select","menuShouldPortal","inputId","options","newValue","width","Switch","id","target","checked","TagFilter","allowCustomValue","formatCreateLabel","input","tagOptions","getAnnotationTags","css","counter","GrafanaDatasource","DataSourceWithBackend","constructor","instanceSettings","super","this","annotations","QueryEditor","prepareAnnotation","json","prepareQuery","anno","datasource","isString","ref","migrateDatasourceNameToRef","name","Annotations","request","results","targets","templateSrv","getTemplateSrv","from","getAnnotations","range","rangeRaw","raw","annotation","dashboard","getDashboardSrv","getCurrent","hide","LiveMeasurements","channel","replace","scopedVars","filter","startsWith","addr","parseLiveChannelAddress","isValidLiveChannelAddress","buffer","maxLength","maxDataPoints","maxDelta","to","valueOf","push","getGrafanaLiveSrv","getDataStream","key","requestId","length","merge","of","listFiles","path","List","pipe","v","frame","data","MutableDataFrame","DataFrameView","metricFindQuery","Promise","resolve","params","dashboardId","Array","isArray","delimiter","t","renderedValues","join","tt","split","getBackendSrv","get","toDataFrame","testDatasource","PureComponent","channels","channelFields","sel","onRunQuery","props","loadChannelInfo","item","fields","tf","state","find","f","txt","rangeUtil","err","console","warn","e","checkAndUpdateBuffer","fetch","url","subscribe","next","channelInfo","c","distinctFields","Set","dataFrameFromJSON","add","n","minute_rate","setState","loadFolderInfo","getDataSourceSrv","then","ds","rsp","folders","values","toArray","componentDidMount","renderMeasurementsQuery","currentChannel","has","formattedTime","InlineField","grow","labelWidth","onChannelChange","backspaceRemovesValue","placeholder","isClearable","noOptionsMessage","onFieldNamesChange","isSearchable","isMulti","Input","defaultValue","onKeyDown","handleEnterKey","onBlur","handleBlur","spellCheck","Alert","title","severity","renderListPublicFiles","currentFolder","InlineFieldRow","onFolderChanged","render","queryTypes","onQueryTypeChange","plugin","DataSourcePlugin","setQueryEditor"],"sourceRoot":""}