@perses-dev/plugin-system 0.54.0-beta.0 → 0.54.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +283 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +197 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
- package/dist/cjs/components/Annotations/constants.js +23 -0
- package/dist/cjs/components/Annotations/index.js +31 -0
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +3 -3
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
- package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
- package/dist/cjs/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -15
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
- package/dist/cjs/components/Variables/variable-model.js +115 -29
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/ValidationProvider.js +10 -4
- package/dist/cjs/model/alerts-queries.js +16 -0
- package/dist/cjs/model/annotations.js +16 -0
- package/dist/cjs/model/calculations.js +178 -0
- package/dist/cjs/model/index.js +4 -0
- package/dist/cjs/model/legend.js +6 -5
- package/dist/cjs/model/log-volume-utils.js +10 -10
- package/dist/cjs/model/plugin-loading.js +24 -8
- package/dist/cjs/model/plugins.js +10 -0
- package/dist/cjs/model/silences-queries.js +16 -0
- package/dist/cjs/model/time-series-queries.js +10 -0
- package/dist/cjs/remote/PluginRuntime.js +46 -10
- package/dist/cjs/remote/remotePluginLoader.js +28 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +33 -24
- package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -93
- package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +101 -0
- package/dist/cjs/runtime/annotations.js +148 -0
- package/dist/cjs/runtime/index.js +3 -1
- package/dist/cjs/runtime/item-actions.js +3 -3
- package/dist/cjs/runtime/log-queries.js +4 -1
- package/dist/cjs/runtime/plugin-registry.js +12 -3
- package/dist/cjs/runtime/profile-queries.js +4 -1
- package/dist/cjs/runtime/silences-queries.js +101 -0
- package/dist/cjs/runtime/time-series-queries.js +4 -1
- package/dist/cjs/runtime/trace-queries.js +4 -1
- package/dist/cjs/test/mock-data.js +51 -0
- package/dist/cjs/test/test-plugins/bert/index.js +9 -12
- package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
- package/dist/cjs/test/test-plugins/index.js +2 -2
- package/dist/cjs/test/utils.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/cjs/utils/index.js +0 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +184 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
- package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js} +2 -13
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
- package/dist/components/Annotations/constants.d.ts +2 -0
- package/dist/components/Annotations/constants.d.ts.map +1 -0
- package/dist/components/Annotations/constants.js +15 -0
- package/dist/components/Annotations/constants.js.map +1 -0
- package/dist/components/Annotations/index.d.ts +3 -0
- package/dist/components/Annotations/index.d.ts.map +1 -0
- package/dist/components/Annotations/index.js +16 -0
- package/dist/components/Annotations/index.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +2 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +100 -15
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.d.ts +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +1 -0
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
- package/dist/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -12
- package/dist/components/MultiQueryEditor/utils.js.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -8
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +9 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +117 -31
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +4 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +10 -4
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +33 -0
- package/dist/model/alerts-queries.d.ts.map +1 -0
- package/dist/model/alerts-queries.js +15 -0
- package/dist/model/alerts-queries.js.map +1 -0
- package/dist/model/annotations.d.ts +28 -0
- package/dist/model/annotations.d.ts.map +1 -0
- package/dist/model/annotations.js +17 -0
- package/dist/model/annotations.js.map +1 -0
- package/dist/model/calculations.d.ts +45 -0
- package/dist/model/calculations.d.ts.map +1 -0
- package/dist/model/calculations.js +165 -0
- package/dist/model/calculations.js.map +1 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +4 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +3 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +2 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts +2 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +24 -8
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +23 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js +4 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/silences-queries.d.ts +33 -0
- package/dist/model/silences-queries.d.ts.map +1 -0
- package/dist/model/silences-queries.js +15 -0
- package/dist/model/silences-queries.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +11 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js +4 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +2 -3
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +2 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
- package/dist/remote/PersesPlugin.types.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +7 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +46 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +28 -5
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +35 -26
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +0 -82
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.js +1 -1
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +2 -2
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +11 -0
- package/dist/runtime/alerts-queries.d.ts.map +1 -0
- package/dist/runtime/alerts-queries.js +89 -0
- package/dist/runtime/alerts-queries.js.map +1 -0
- package/dist/runtime/annotations.d.ts +6 -0
- package/dist/runtime/annotations.d.ts.map +1 -0
- package/dist/runtime/annotations.js +129 -0
- package/dist/runtime/annotations.js.map +1 -0
- package/dist/runtime/datasources.d.ts +6 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/log-queries.js +4 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +12 -3
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.js +4 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +11 -0
- package/dist/runtime/silences-queries.d.ts.map +1 -0
- package/dist/runtime/silences-queries.js +89 -0
- package/dist/runtime/silences-queries.js.map +1 -0
- package/dist/runtime/time-series-queries.js +4 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +4 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +45 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts +12 -6
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +6 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +8 -6
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +6 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +2 -2
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +2 -2
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +8 -2
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/runtime/QueryCountProvider.js +0 -83
- package/dist/runtime/QueryCountProvider.d.ts +0 -9
- package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
- package/dist/runtime/QueryCountProvider.js.map +0 -1
- package/dist/utils/action.d.ts +0 -4
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/action.js.map +0 -1
|
@@ -39,6 +39,8 @@ const _react = require("react");
|
|
|
39
39
|
const _timeseriesqueries = require("../time-series-queries");
|
|
40
40
|
const _tracequeries = require("../trace-queries");
|
|
41
41
|
const _profilequeries = require("../profile-queries");
|
|
42
|
+
const _alertsqueries = require("../alerts-queries");
|
|
43
|
+
const _silencesqueries = require("../silences-queries");
|
|
42
44
|
const _UsageMetricsProvider = require("../UsageMetricsProvider");
|
|
43
45
|
const _logqueries = require("../log-queries");
|
|
44
46
|
const _model = require("./model");
|
|
@@ -52,60 +54,61 @@ function useDataQueriesContext() {
|
|
|
52
54
|
}
|
|
53
55
|
function useDataQueries(queryType) {
|
|
54
56
|
const ctx = useDataQueriesContext();
|
|
57
|
+
// Filter query definitions based on the specified query type
|
|
58
|
+
const filteredQueryDefinitions = ctx.queryDefinitions.filter((definition)=>definition.kind === queryType);
|
|
55
59
|
// Filter the query results based on the specified query type
|
|
56
60
|
const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult?.definition?.kind === queryType);
|
|
57
61
|
// Filter the errors based on the specified query type
|
|
58
62
|
const filteredErrors = ctx.errors.filter((errors, index)=>ctx.queryResults[index]?.definition?.kind === queryType);
|
|
59
63
|
// Create a new context object with the filtered results and errors
|
|
60
|
-
|
|
64
|
+
return {
|
|
65
|
+
queryDefinitions: filteredQueryDefinitions,
|
|
61
66
|
queryResults: filteredQueryResults,
|
|
62
67
|
isFetching: filteredQueryResults.some((result)=>result.isFetching),
|
|
63
68
|
isLoading: filteredQueryResults.some((result)=>result.isLoading),
|
|
64
69
|
refetchAll: ctx.refetchAll,
|
|
65
70
|
errors: filteredErrors
|
|
66
71
|
};
|
|
67
|
-
return filteredCtx;
|
|
68
72
|
}
|
|
69
73
|
function DataQueriesProvider(props) {
|
|
70
74
|
const { definitions, options, children, queryOptions } = props;
|
|
71
|
-
// Returns a query kind, for example "TimeSeriesQuery" = getQueryType("PrometheusTimeSeriesQuery")
|
|
72
|
-
const getQueryType = (0, _model.useQueryType)();
|
|
73
|
-
const queryDefinitions = definitions.map((definition)=>{
|
|
74
|
-
const type = getQueryType(definition.kind);
|
|
75
|
-
return {
|
|
76
|
-
kind: type,
|
|
77
|
-
spec: {
|
|
78
|
-
plugin: definition
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
75
|
const usageMetrics = (0, _UsageMetricsProvider.useUsageMetrics)();
|
|
83
76
|
// Filter definitions for time series query and other future query plugins
|
|
84
|
-
const timeSeriesQueries =
|
|
77
|
+
const timeSeriesQueries = definitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
|
|
85
78
|
const timeSeriesResults = (0, _timeseriesqueries.useTimeSeriesQueries)(timeSeriesQueries, options, queryOptions);
|
|
86
|
-
const traceQueries =
|
|
79
|
+
const traceQueries = definitions.filter((definition)=>definition.kind === 'TraceQuery');
|
|
87
80
|
const traceResults = (0, _tracequeries.useTraceQueries)(traceQueries);
|
|
88
|
-
const profileQueries =
|
|
81
|
+
const profileQueries = definitions.filter((definition)=>definition.kind === 'ProfileQuery');
|
|
89
82
|
const profileResults = (0, _profilequeries.useProfileQueries)(profileQueries);
|
|
90
|
-
const logQueries =
|
|
83
|
+
const logQueries = definitions.filter((definition)=>definition.kind === 'LogQuery');
|
|
91
84
|
const logResults = (0, _logqueries.useLogQueries)(logQueries);
|
|
85
|
+
const alertsQueries = definitions.filter((definition)=>definition.kind === 'AlertsQuery');
|
|
86
|
+
const alertsResults = (0, _alertsqueries.useAlertsQueries)(alertsQueries);
|
|
87
|
+
const silencesQueries = definitions.filter((definition)=>definition.kind === 'SilencesQuery');
|
|
88
|
+
const silencesResults = (0, _silencesqueries.useSilencesQueries)(silencesQueries);
|
|
92
89
|
const refetchAll = (0, _react.useCallback)(()=>{
|
|
93
90
|
timeSeriesResults.forEach((result)=>result.refetch());
|
|
94
91
|
traceResults.forEach((result)=>result.refetch());
|
|
95
92
|
profileResults.forEach((result)=>result.refetch());
|
|
96
93
|
logResults.forEach((result)=>result.refetch());
|
|
94
|
+
alertsResults.forEach((result)=>result.refetch());
|
|
95
|
+
silencesResults.forEach((result)=>result.refetch());
|
|
97
96
|
}, [
|
|
98
97
|
timeSeriesResults,
|
|
99
98
|
traceResults,
|
|
100
99
|
profileResults,
|
|
101
|
-
logResults
|
|
100
|
+
logResults,
|
|
101
|
+
alertsResults,
|
|
102
|
+
silencesResults
|
|
102
103
|
]);
|
|
103
104
|
const ctx = (0, _react.useMemo)(()=>{
|
|
104
105
|
const mergedQueryResults = [
|
|
105
106
|
...(0, _model.transformQueryResults)(timeSeriesResults, timeSeriesQueries),
|
|
106
107
|
...(0, _model.transformQueryResults)(traceResults, traceQueries),
|
|
107
108
|
...(0, _model.transformQueryResults)(profileResults, profileQueries),
|
|
108
|
-
...(0, _model.transformQueryResults)(logResults, logQueries)
|
|
109
|
+
...(0, _model.transformQueryResults)(logResults, logQueries),
|
|
110
|
+
...(0, _model.transformQueryResults)(alertsResults, alertsQueries),
|
|
111
|
+
...(0, _model.transformQueryResults)(silencesResults, silencesQueries)
|
|
109
112
|
];
|
|
110
113
|
if (queryOptions?.enabled) {
|
|
111
114
|
for (const result of mergedQueryResults){
|
|
@@ -119,6 +122,7 @@ function DataQueriesProvider(props) {
|
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
return {
|
|
125
|
+
queryDefinitions: definitions,
|
|
122
126
|
queryResults: mergedQueryResults,
|
|
123
127
|
isFetching: mergedQueryResults.some((result)=>result.isFetching),
|
|
124
128
|
isLoading: mergedQueryResults.some((result)=>result.isLoading),
|
|
@@ -126,16 +130,21 @@ function DataQueriesProvider(props) {
|
|
|
126
130
|
errors: mergedQueryResults.map((result)=>result.error)
|
|
127
131
|
};
|
|
128
132
|
}, [
|
|
133
|
+
alertsQueries,
|
|
134
|
+
alertsResults,
|
|
135
|
+
logQueries,
|
|
136
|
+
logResults,
|
|
137
|
+
profileQueries,
|
|
138
|
+
profileResults,
|
|
139
|
+
silencesQueries,
|
|
140
|
+
silencesResults,
|
|
129
141
|
timeSeriesQueries,
|
|
130
142
|
timeSeriesResults,
|
|
131
143
|
traceQueries,
|
|
132
144
|
traceResults,
|
|
133
|
-
|
|
134
|
-
profileResults,
|
|
135
|
-
logQueries,
|
|
136
|
-
logResults,
|
|
137
|
-
refetchAll,
|
|
145
|
+
definitions,
|
|
138
146
|
queryOptions?.enabled,
|
|
147
|
+
refetchAll,
|
|
139
148
|
usageMetrics
|
|
140
149
|
]);
|
|
141
150
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(DataQueriesContext.Provider, {
|
|
@@ -14,22 +14,12 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get transformQueryResults () {
|
|
17
|
+
Object.defineProperty(exports, "transformQueryResults", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
25
20
|
return transformQueryResults;
|
|
26
|
-
},
|
|
27
|
-
get useQueryType () {
|
|
28
|
-
return useQueryType;
|
|
29
21
|
}
|
|
30
22
|
});
|
|
31
|
-
const _react = require("react");
|
|
32
|
-
const _pluginregistry = require("../plugin-registry");
|
|
33
23
|
function transformQueryResults(results, definitions) {
|
|
34
24
|
return results.map(({ data, isFetching, isLoading, refetch, error }, i)=>{
|
|
35
25
|
return {
|
|
@@ -42,83 +32,3 @@ function transformQueryResults(results, definitions) {
|
|
|
42
32
|
};
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
|
-
function useQueryType() {
|
|
46
|
-
const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
47
|
-
'TimeSeriesQuery'
|
|
48
|
-
]);
|
|
49
|
-
const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
50
|
-
'TraceQuery'
|
|
51
|
-
]);
|
|
52
|
-
const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
53
|
-
'ProfileQuery'
|
|
54
|
-
]);
|
|
55
|
-
const { data: logQueries, isLoading: isLogQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
56
|
-
'LogQuery'
|
|
57
|
-
]);
|
|
58
|
-
// For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
|
|
59
|
-
const queryTypeMap = (0, _react.useMemo)(()=>{
|
|
60
|
-
const map = {
|
|
61
|
-
TimeSeriesQuery: [],
|
|
62
|
-
TraceQuery: [],
|
|
63
|
-
ProfileQuery: [],
|
|
64
|
-
LogQuery: []
|
|
65
|
-
};
|
|
66
|
-
if (timeSeriesQueryPlugins) {
|
|
67
|
-
timeSeriesQueryPlugins.forEach((plugin)=>{
|
|
68
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (traceQueryPlugins) {
|
|
72
|
-
traceQueryPlugins.forEach((plugin)=>{
|
|
73
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (profileQueryPlugins) {
|
|
77
|
-
profileQueryPlugins.forEach((plugin)=>{
|
|
78
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (logQueries) {
|
|
82
|
-
logQueries.forEach((plugin)=>{
|
|
83
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return map;
|
|
87
|
-
}, [
|
|
88
|
-
timeSeriesQueryPlugins,
|
|
89
|
-
traceQueryPlugins,
|
|
90
|
-
profileQueryPlugins,
|
|
91
|
-
logQueries
|
|
92
|
-
]);
|
|
93
|
-
const getQueryType = (0, _react.useCallback)((pluginKind)=>{
|
|
94
|
-
const isLoading = (pluginKind)=>{
|
|
95
|
-
switch(pluginKind){
|
|
96
|
-
case 'PrometheusTimeSeriesQuery':
|
|
97
|
-
return isTimeSeriesQueryLoading;
|
|
98
|
-
case 'TempoTraceQuery':
|
|
99
|
-
return isTraceQueryPluginLoading;
|
|
100
|
-
case 'PyroscopeProfileQuery':
|
|
101
|
-
return isProfileQueryPluginLoading;
|
|
102
|
-
case 'LokiLogQuery':
|
|
103
|
-
return isLogQueryPluginLoading;
|
|
104
|
-
}
|
|
105
|
-
return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading;
|
|
106
|
-
};
|
|
107
|
-
if (isLoading(pluginKind)) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
for(const queryType in queryTypeMap){
|
|
111
|
-
if (queryTypeMap[queryType]?.includes(pluginKind)) {
|
|
112
|
-
return queryType;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
throw new Error(`Unable to determine the query type: ${pluginKind}`);
|
|
116
|
-
}, [
|
|
117
|
-
queryTypeMap,
|
|
118
|
-
isTimeSeriesQueryLoading,
|
|
119
|
-
isTraceQueryPluginLoading,
|
|
120
|
-
isProfileQueryPluginLoading,
|
|
121
|
-
isLogQueryPluginLoading
|
|
122
|
-
]);
|
|
123
|
-
return getQueryType;
|
|
124
|
-
}
|
|
@@ -35,7 +35,7 @@ _export(exports, {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const _jsxruntime = require("react/jsx-runtime");
|
|
38
|
-
const
|
|
38
|
+
const _client = require("@perses-dev/client");
|
|
39
39
|
const _react = require("react");
|
|
40
40
|
const UsageMetricsContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
41
41
|
const useUsageMetricsContext = ()=>{
|
|
@@ -70,7 +70,7 @@ const useUsageMetrics = ()=>{
|
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
const submitMetrics = async (stats)=>{
|
|
73
|
-
await (0,
|
|
73
|
+
await (0, _client.fetch)(`${stats.apiPrefix ?? ''}/api/v1/view`, {
|
|
74
74
|
method: 'POST',
|
|
75
75
|
headers: {
|
|
76
76
|
'Content-Type': 'application/json'
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get ALERTS_QUERY_KEY () {
|
|
25
|
+
return ALERTS_QUERY_KEY;
|
|
26
|
+
},
|
|
27
|
+
get useAlertsQueries () {
|
|
28
|
+
return useAlertsQueries;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _reactquery = require("@tanstack/react-query");
|
|
32
|
+
const _datasources = require("./datasources");
|
|
33
|
+
const _pluginregistry = require("./plugin-registry");
|
|
34
|
+
const _variables = require("./variables");
|
|
35
|
+
const _utils = require("./utils");
|
|
36
|
+
const ALERTS_QUERY_KEY = 'AlertsQuery';
|
|
37
|
+
function useAlertsQueries(definitions) {
|
|
38
|
+
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
39
|
+
const context = useAlertsQueryContext();
|
|
40
|
+
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('AlertsQuery', definitions.map((d)=>({
|
|
41
|
+
kind: d.spec.plugin.kind
|
|
42
|
+
})));
|
|
43
|
+
return (0, _reactquery.useQueries)({
|
|
44
|
+
queries: definitions.map((definition, idx)=>{
|
|
45
|
+
const plugin = pluginLoaderResponse[idx]?.data;
|
|
46
|
+
const { queryEnabled, queryKey } = getQueryOptions({
|
|
47
|
+
context,
|
|
48
|
+
definition,
|
|
49
|
+
plugin
|
|
50
|
+
});
|
|
51
|
+
const alertsQueryKind = definition?.spec?.plugin?.kind;
|
|
52
|
+
return {
|
|
53
|
+
enabled: queryEnabled,
|
|
54
|
+
queryKey: queryKey,
|
|
55
|
+
refetchOnMount: false,
|
|
56
|
+
refetchOnWindowFocus: false,
|
|
57
|
+
refetchOnReconnect: false,
|
|
58
|
+
staleTime: 60_000,
|
|
59
|
+
queryFn: async ({ signal })=>{
|
|
60
|
+
const plugin = await getPlugin({
|
|
61
|
+
kind: ALERTS_QUERY_KEY,
|
|
62
|
+
name: alertsQueryKind
|
|
63
|
+
});
|
|
64
|
+
const data = await plugin.getAlertsData(definition.spec.plugin.spec, context, signal);
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function getQueryOptions({ plugin, definition, context }) {
|
|
72
|
+
const { variableState } = context;
|
|
73
|
+
const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
74
|
+
const variableDependencies = dependencies?.variables;
|
|
75
|
+
const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
|
|
76
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
|
|
77
|
+
// Note: no absoluteTimeRange in query key since alerts are current state
|
|
78
|
+
const queryKey = [
|
|
79
|
+
'query',
|
|
80
|
+
ALERTS_QUERY_KEY,
|
|
81
|
+
definition,
|
|
82
|
+
variablesValueKey
|
|
83
|
+
];
|
|
84
|
+
let waitToLoad = false;
|
|
85
|
+
if (variableDependencies) {
|
|
86
|
+
waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
|
|
87
|
+
}
|
|
88
|
+
const queryEnabled = plugin !== undefined && !waitToLoad;
|
|
89
|
+
return {
|
|
90
|
+
queryKey,
|
|
91
|
+
queryEnabled
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function useAlertsQueryContext() {
|
|
95
|
+
const variableState = (0, _variables.useAllVariableValues)();
|
|
96
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
97
|
+
return {
|
|
98
|
+
variableState,
|
|
99
|
+
datasourceStore
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get ANNOTATION_KEY () {
|
|
25
|
+
return ANNOTATION_KEY;
|
|
26
|
+
},
|
|
27
|
+
get useAnnotationData () {
|
|
28
|
+
return useAnnotationData;
|
|
29
|
+
},
|
|
30
|
+
get useAnnotations () {
|
|
31
|
+
return useAnnotations;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _reactquery = require("@tanstack/react-query");
|
|
35
|
+
const _pluginregistry = require("./plugin-registry");
|
|
36
|
+
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
37
|
+
const _variables = require("./variables");
|
|
38
|
+
const _datasources = require("./datasources");
|
|
39
|
+
const _utils = require("./utils");
|
|
40
|
+
const ANNOTATION_KEY = 'Annotation';
|
|
41
|
+
function useAnnotationContext() {
|
|
42
|
+
const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
|
|
43
|
+
const variableState = (0, _variables.useAllVariableValues)();
|
|
44
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
45
|
+
return {
|
|
46
|
+
variableState,
|
|
47
|
+
datasourceStore,
|
|
48
|
+
absoluteTimeRange
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function getQueryOptions({ plugin, definition, context }) {
|
|
52
|
+
const { variableState, absoluteTimeRange } = context;
|
|
53
|
+
const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.plugin.spec, context) : {};
|
|
54
|
+
const variableDependencies = dependencies?.variables;
|
|
55
|
+
const filteredVariableState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
|
|
56
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariableState);
|
|
57
|
+
const queryKey = [
|
|
58
|
+
ANNOTATION_KEY,
|
|
59
|
+
definition,
|
|
60
|
+
absoluteTimeRange,
|
|
61
|
+
variablesValueKey
|
|
62
|
+
];
|
|
63
|
+
let waitToLoad = false;
|
|
64
|
+
if (variableDependencies) {
|
|
65
|
+
waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
|
|
66
|
+
}
|
|
67
|
+
const queryEnabled = plugin !== undefined && !waitToLoad;
|
|
68
|
+
return {
|
|
69
|
+
queryKey,
|
|
70
|
+
queryEnabled
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function useAnnotations(definitions) {
|
|
74
|
+
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
75
|
+
const context = useAnnotationContext();
|
|
76
|
+
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('Annotation', definitions.map((d)=>({
|
|
77
|
+
kind: d.plugin.kind
|
|
78
|
+
})));
|
|
79
|
+
// useQueries() handles data fetching from query plugins
|
|
80
|
+
return (0, _reactquery.useQueries)({
|
|
81
|
+
queries: definitions.map((definition, idx)=>{
|
|
82
|
+
const plugin = pluginLoaderResponse[idx]?.data;
|
|
83
|
+
const { queryEnabled, queryKey } = getQueryOptions({
|
|
84
|
+
context,
|
|
85
|
+
definition,
|
|
86
|
+
plugin
|
|
87
|
+
});
|
|
88
|
+
const annotationKind = definition?.plugin?.kind;
|
|
89
|
+
return {
|
|
90
|
+
enabled: queryEnabled,
|
|
91
|
+
queryKey: queryKey,
|
|
92
|
+
refetchOnMount: false,
|
|
93
|
+
refetchOnWindowFocus: false,
|
|
94
|
+
refetchOnReconnect: false,
|
|
95
|
+
staleTime: Infinity,
|
|
96
|
+
queryFn: async ({ signal })=>{
|
|
97
|
+
const plugin = await getPlugin({
|
|
98
|
+
kind: ANNOTATION_KEY,
|
|
99
|
+
name: annotationKind
|
|
100
|
+
});
|
|
101
|
+
const data = await plugin.getAnnotationData(definition.plugin.spec, context, signal);
|
|
102
|
+
return data;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function useAnnotationData(spec) {
|
|
109
|
+
const { data: annotationPlugin } = (0, _pluginregistry.usePlugin)('Annotation', spec.plugin.kind);
|
|
110
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
111
|
+
const allVariables = (0, _variables.useAllVariableValues)();
|
|
112
|
+
const { absoluteTimeRange: timeRange } = (0, _TimeRangeProvider.useTimeRange)();
|
|
113
|
+
const variablePluginCtx = {
|
|
114
|
+
absoluteTimeRange: timeRange,
|
|
115
|
+
datasourceStore,
|
|
116
|
+
variableState: allVariables
|
|
117
|
+
};
|
|
118
|
+
let dependsOnVariables = Object.keys(allVariables); // Default to all variables
|
|
119
|
+
if (annotationPlugin?.dependsOn) {
|
|
120
|
+
const dependencies = annotationPlugin.dependsOn(spec.plugin.spec, variablePluginCtx);
|
|
121
|
+
dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;
|
|
122
|
+
}
|
|
123
|
+
const variables = (0, _variables.useAllVariableValues)(dependsOnVariables);
|
|
124
|
+
let waitToLoad = false;
|
|
125
|
+
if (dependsOnVariables) {
|
|
126
|
+
waitToLoad = dependsOnVariables.some((v)=>variables[v]?.loading);
|
|
127
|
+
}
|
|
128
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(variables);
|
|
129
|
+
return (0, _reactquery.useQuery)({
|
|
130
|
+
queryKey: [
|
|
131
|
+
'annotation',
|
|
132
|
+
spec,
|
|
133
|
+
timeRange,
|
|
134
|
+
variablesValueKey
|
|
135
|
+
],
|
|
136
|
+
queryFn: async ({ signal })=>{
|
|
137
|
+
const resp = await annotationPlugin?.getAnnotationData(spec.plugin.spec, {
|
|
138
|
+
...variablePluginCtx,
|
|
139
|
+
variableState: variables
|
|
140
|
+
}, signal);
|
|
141
|
+
if (!resp?.length) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return resp;
|
|
145
|
+
},
|
|
146
|
+
enabled: !!annotationPlugin || waitToLoad
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_export_star(require("./annotations"), exports);
|
|
17
18
|
_export_star(require("./builtin-variables"), exports);
|
|
18
19
|
_export_star(require("./datasources"), exports);
|
|
19
20
|
_export_star(require("./plugin-registry"), exports);
|
|
@@ -22,9 +23,10 @@ _export_star(require("./TimeRangeProvider"), exports);
|
|
|
22
23
|
_export_star(require("./time-series-queries"), exports);
|
|
23
24
|
_export_star(require("./trace-queries"), exports);
|
|
24
25
|
_export_star(require("./profile-queries"), exports);
|
|
26
|
+
_export_star(require("./alerts-queries"), exports);
|
|
27
|
+
_export_star(require("./silences-queries"), exports);
|
|
25
28
|
_export_star(require("./item-actions"), exports);
|
|
26
29
|
_export_star(require("./DataQueriesProvider"), exports);
|
|
27
|
-
_export_star(require("./QueryCountProvider"), exports);
|
|
28
30
|
_export_star(require("./RouterProvider"), exports);
|
|
29
31
|
_export_star(require("./UsageMetricsProvider"), exports);
|
|
30
32
|
function _export_star(from, to) {
|
|
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "executeAction", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _components = require("@perses-dev/components");
|
|
24
|
-
const
|
|
24
|
+
const _client = require("@perses-dev/client");
|
|
25
25
|
const BODY_METHODS = new Set([
|
|
26
26
|
'POST',
|
|
27
27
|
'PUT',
|
|
@@ -174,7 +174,7 @@ function buildWebhookHeaders(action) {
|
|
|
174
174
|
body = bodyResult.text;
|
|
175
175
|
}
|
|
176
176
|
// Make the request
|
|
177
|
-
const response = await (0,
|
|
177
|
+
const response = await (0, _client.fetch)(urlResult.text, {
|
|
178
178
|
method: action.method,
|
|
179
179
|
headers: buildWebhookHeaders(action),
|
|
180
180
|
body: body
|
|
@@ -239,7 +239,7 @@ function buildWebhookHeaders(action) {
|
|
|
239
239
|
body = bodyResult.text;
|
|
240
240
|
}
|
|
241
241
|
// Make the request
|
|
242
|
-
const response = await (0,
|
|
242
|
+
const response = await (0, _client.fetch)(urlResult.text, {
|
|
243
243
|
method: action.method,
|
|
244
244
|
headers: buildWebhookHeaders(action),
|
|
245
245
|
body: body
|
|
@@ -62,7 +62,10 @@ function useLogQueries(definitions) {
|
|
|
62
62
|
refetchOnReconnect: false,
|
|
63
63
|
staleTime: Infinity,
|
|
64
64
|
queryFn: async ({ signal })=>{
|
|
65
|
-
const plugin = await getPlugin(
|
|
65
|
+
const plugin = await getPlugin({
|
|
66
|
+
kind: LOG_QUERY_KEY,
|
|
67
|
+
name: logQueryKind
|
|
68
|
+
});
|
|
66
69
|
const data = await plugin.getLogData(definition.spec.plugin.spec, context, signal);
|
|
67
70
|
return data;
|
|
68
71
|
},
|
|
@@ -63,7 +63,10 @@ function usePlugin(pluginType, kind, options) {
|
|
|
63
63
|
pluginType,
|
|
64
64
|
kind
|
|
65
65
|
],
|
|
66
|
-
queryFn: ()=>getPlugin(
|
|
66
|
+
queryFn: ()=>getPlugin({
|
|
67
|
+
kind: pluginType,
|
|
68
|
+
name: kind
|
|
69
|
+
}),
|
|
67
70
|
...options
|
|
68
71
|
});
|
|
69
72
|
}
|
|
@@ -84,7 +87,10 @@ function usePlugins(pluginType, plugins) {
|
|
|
84
87
|
pluginType,
|
|
85
88
|
kind
|
|
86
89
|
],
|
|
87
|
-
queryFn: ()=>getPlugin(
|
|
90
|
+
queryFn: ()=>getPlugin({
|
|
91
|
+
kind: pluginType,
|
|
92
|
+
name: kind
|
|
93
|
+
})
|
|
88
94
|
};
|
|
89
95
|
})
|
|
90
96
|
});
|
|
@@ -115,7 +121,10 @@ function usePluginBuiltinVariableDefinitions() {
|
|
|
115
121
|
const datasourceNames = new Set(datasources.map((datasource)=>datasource.spec.name));
|
|
116
122
|
const result = [];
|
|
117
123
|
for (const name of datasourceNames){
|
|
118
|
-
const plugin = await getPlugin(
|
|
124
|
+
const plugin = await getPlugin({
|
|
125
|
+
kind: 'Datasource',
|
|
126
|
+
name
|
|
127
|
+
});
|
|
119
128
|
if (plugin.getBuiltinVariableDefinitions) {
|
|
120
129
|
plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
|
|
121
130
|
}
|
|
@@ -59,7 +59,10 @@ function useProfileQueries(definitions) {
|
|
|
59
59
|
refetchOnReconnect: false,
|
|
60
60
|
staleTime: Infinity,
|
|
61
61
|
queryFn: async ({ signal })=>{
|
|
62
|
-
const plugin = await getPlugin(
|
|
62
|
+
const plugin = await getPlugin({
|
|
63
|
+
kind: PROFILE_QUERY_KEY,
|
|
64
|
+
name: profileQueryKind
|
|
65
|
+
});
|
|
63
66
|
const data = await plugin.getProfileData(definition.spec.plugin.spec, context, signal);
|
|
64
67
|
return data;
|
|
65
68
|
},
|