Skip to content

Commit

Permalink
Merge branch 'v10.4.x-logzio' into DEV-45405-fix-grafana-tests-second…
Browse files Browse the repository at this point in the history
…-run
  • Loading branch information
yasmin-tr committed Oct 31, 2024
2 parents 26fe650 + 2996e94 commit 9c1dcf3
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 38 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -189,5 +189,9 @@ ARG RUN_SH=grafana/packaging/docker/run.sh

COPY ${RUN_SH} /run.sh

# LOGZ.IO GRAFANA CHANGE :: Add unique file to avoid ECR tag limit
ARG VERSION
RUN echo "$VERSION" > /var/version.txt

USER "$GF_UID"
ENTRYPOINT [ "/run.sh" ]
ENTRYPOINT [ "/run.sh" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ test-go-unit: ## Run unit tests for backend with flags.
.PHONY: test-go-integration
test-go-integration: ## Run integration tests for backend with flags.
@echo "test backend integration tests"
$(GO) test -count=1 -run "^TestIntegration" -covermode=atomic -timeout=5m $(GO_INTEGRATION_TESTS)
$(GO) test -count=1 -run "^TestIntegration" -covermode=atomic -timeout=10m $(GO_INTEGRATION_TESTS)

.PHONY: test-go-integration-alertmanager
test-go-integration-alertmanager: ## Run integration tests for the remote alertmanager (config taken from the mimir_backend block).
Expand Down
3 changes: 2 additions & 1 deletion custom.ini
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ custom_endpoint = log

[feature_toggles]
prometheusPromQAIL = false
publicDashboards = false
publicDashboards = false
autoMigratePiechartPanel = true
6 changes: 4 additions & 2 deletions packages/grafana-prometheus/src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,10 @@ export class PrometheusDatasource

async loadRules() {
try {
const res = await this.metadataRequest('/api/v1/rules', {}, { showErrorAlert: false });
const groups = res.data?.data?.groups;
// LOGZ.IO GRAFANA CHANGE :: DEV-46445-disable-recording-rules-fetch-in-grafana-10
// const res = await this.metadataRequest('/api/v1/rules', {}, { showErrorAlert: false });
// const groups = res.data?.data?.groups;
const groups = null;

if (groups) {
this.ruleMappings = extractRuleMappingFromGroups(groups);
Expand Down
13 changes: 3 additions & 10 deletions public/app/core/components/SharedPreferences/SharedPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { DashboardPicker } from 'app/core/components/Select/DashboardPicker';
import { t, Trans } from 'app/core/internationalization';
import { LANGUAGES } from 'app/core/internationalization/constants';
import { PreferencesService } from 'app/core/services/PreferencesService';
import { backendSrv } from "app/core/services/backend_srv";// LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard
import { changeTheme } from 'app/core/services/theme';

export interface Props {
Expand Down Expand Up @@ -75,7 +74,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
}

async componentDidMount() {
const prefs = await backendSrv.get(`/api/${this.props.resourceUri.toLowerCase()}/preferences`);// LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard
const prefs = await this.service.load();

this.setState({
homeDashboardUID: prefs.homeDashboardUID,
Expand All @@ -92,14 +91,8 @@ export class SharedPreferences extends PureComponent<Props, State> {
const confirmationResult = this.props.onConfirm ? await this.props.onConfirm() : true;

if (confirmationResult) {
// LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard
const { homeDashboardUID, theme, timezone } = this.state;
await backendSrv.put(`/api/${this.props.resourceUri.toLowerCase()}/preferences`, {
homeDashboardId: homeDashboardUID,
theme,
timezone,
});
// LOGZ.IO GRAFANA CHANGE :: end
const { homeDashboardUID, theme, timezone, weekStart, language, queryHistory } = this.state;
await this.service.update({ homeDashboardUID, theme, timezone, weekStart, language, queryHistory });
window.location.reload();
}
};
Expand Down
2 changes: 1 addition & 1 deletion public/app/core/services/backend_srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export class BackendSrv implements BackendService {
}

/** @deprecated */
search(query: any): Promise<DashboardSearchItem[]> {
search(query: any): Promise<Array<DashboardSearchItem & {id?: number}>> { // LOGZ.IO GRAFANA CHANGE :: DEV-20609 Home dashboard
return this.get('/api/search', query);
}

Expand Down
1 change: 1 addition & 0 deletions public/app/core/services/impression_srv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class ImpressionSrv {
}

private async convertToUIDs() {
return; // LOGZIO GRAFANA CHANGE :: DEV-46987 - disable convert recent visited dashboards to UID
let impressions = this.getImpressions();
const ids = filter(impressions, (el) => isNumber(el));
if (!ids.length) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/css';
import React from 'react';
import React, {useMemo} from 'react';

import { GrafanaTheme2 } from '@grafana/data';
import { LinkButton, useStyles2 } from '@grafana/ui';
Expand Down Expand Up @@ -27,6 +27,15 @@ export const AlertDetails = ({ alert, alertManagerSourceName }: AmNotificationsA
const isSeeSourceButtonEnabled = isGrafanaSource
? contextSrv.hasPermission(AccessControlAction.AlertingRuleRead)
: true;
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button"
const generatorURL = useMemo(() => {
if (alert.generatorURL) {
const url = new URL(alert.generatorURL);
return url.hash.replace(/^#.dashboard.metrics/, '/grafana-app');
}
return '';
}, [alert.generatorURL]);
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" end

return (
<>
Expand Down Expand Up @@ -58,8 +67,8 @@ export const AlertDetails = ({ alert, alertManagerSourceName }: AmNotificationsA
</LinkButton>
</Authorize>
)}
{isSeeSourceButtonEnabled && alert.generatorURL && (
<LinkButton className={styles.button} href={alert.generatorURL} icon={'chart-line'} size={'sm'}>
{isSeeSourceButtonEnabled && generatorURL && ( /* LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" */
<LinkButton className={styles.button} href={generatorURL} icon={'chart-line'} size={'sm'}>
See source
</LinkButton>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export function GrafanaEvaluationBehavior({
<GrafanaAlertStatePicker
{...field}
// LOGZ.IO GRAFANA CHANGE :: disable edit of error state handling
disabled
inputId="exec-err-state-input"
width={42}
includeNoData={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ import { RuleEditorSection } from '../RuleEditorSection';
import { errorFromCurrentCondition, errorFromPreviewData, findRenamedDataQueryReferences, refIdExists } from '../util';

import { CloudDataSourceSelector } from './CloudDataSourceSelector';
// LOGZ.IO CHANGE :: DEV-46521 remove rule type switch
// import { SmartAlertTypeDetector } from './SmartAlertTypeDetector';
import { SmartAlertTypeDetector } from './SmartAlertTypeDetector';
import { DESCRIPTIONS } from './descriptions';
import {
addExpressions,
Expand Down Expand Up @@ -371,7 +370,7 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
removeExpressionsInQueries,
condition,
]);

const { sectionTitle, helpLabel, helpContent, helpLink } = DESCRIPTIONS[type ?? RuleFormType.grafana];

return (
Expand Down Expand Up @@ -432,14 +431,12 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
}}
/>
</Field>
{/*
// LOGZ.IO CHANGE :: DEV-46521 remove rule type switch
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
queries={queries}
rulesSourcesWithRuler={rulesSourcesWithRuler}
onClickSwitch={onClickSwitch}
/> */}
/>
</Stack>
)}

Expand Down Expand Up @@ -471,14 +468,18 @@ export const QueryAndExpressionsStep = ({ editingExistingRule, onDataChange }: P
Add query
</Button>
</Tooltip>
{/*
// LOGZ.IO CHANGE :: DEV-46521 remove rule type switch
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
rulesSourcesWithRuler={rulesSourcesWithRuler}
queries={queries}
onClickSwitch={onClickSwitch}
/> */}
/>
<SmartAlertTypeDetector
editingExistingRule={editingExistingRule}
rulesSourcesWithRuler={rulesSourcesWithRuler}
queries={queries}
onClickSwitch={onClickSwitch}
/>
{/* Expression Queries */}
<Stack direction="column" gap={0}>
<Text element="h5">Expressions</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export function SmartAlertTypeDetector({
// if we can't switch to data-source managed, disable it
// TODO figure out how to show a popover to the user to indicate _why_ it's disabled
const disabledOptions = canSwitch ? [] : [RuleFormType.cloudAlerting];

return null;

return (
<Stack direction="column" gap={1} alignItems="flex-start">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const RulesFilter = ({ onFilterCleared = () => undefined }: RulesFilerProps) =>
onChange={handleAlertStateChange}
/>
</div>
<div>
<div hidden>{ /* LOGZ.IO GRAFANA CHANGE :: disable recording rules filter */ }
<Label>Rule type</Label>
<RadioButtonGroup options={RuleTypeOptions} value={filterState.ruleType} onChange={handleRuleTypeChange} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ interface PluginBridgeHookResponse {
}

export function usePluginBridge(plugin: PluginID): PluginBridgeHookResponse {
const { loading, error, value } = useAsync(() => getPluginSettings(plugin, { showErrorAlert: false }));
// LOGZ.IO CHANGE :: DEV-46522 disable the oncall grafana plugin
if (plugin === SupportedPlugin.OnCall) {
return { loading: false, installed: false};
}
// LOGZ.IO CHANGE :: DEV-46522 disable the oncall grafana plugin. END
const { loading, error, value } = useAsync(() => getPluginSettings(plugin, { showErrorAlert: false }));

const installed = value && !error && !loading;
const enabled = value?.enabled;
const isLoading = loading && !value;
Expand Down
1 change: 1 addition & 0 deletions public/app/features/dashboard/components/GenAI/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function getDashboardChanges(dashboard: DashboardModel): {
* @returns true if the LLM plugin is enabled.
*/
export async function isLLMPluginEnabled() {
return Promise.resolve(false); // LOGZ.IO GRAFANA CHANGE :: DEV-44665-grafana-upgrade-remove-llm
// Check if the LLM plugin is enabled.
// If not, we won't be able to make requests, so return early.
return llms.openai.health().then((response) => response.ok);
Expand Down
4 changes: 2 additions & 2 deletions public/app/features/playlist/ShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const ShareModal = ({ playlistUid, onDismiss }: Props) => {

const params: UrlQueryMap = {};
if (mode) {
params.kiosk = mode;
}
params.kiosk = mode.toString(); // LOGZ.IO GRAFANA CHANGE :: DEV-42761 fix playlist sharing url
}
if (autoFit) {
params.autofitpanels = true;
}
Expand Down
5 changes: 4 additions & 1 deletion public/app/plugins/datasource/elasticsearch/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,9 @@ export class ElasticDatasource
if (index && index.mappings) {
const mappings = index.mappings;

const properties = mappings.properties;
// LOGZ.IO GRAFANA CHANGE :: DEV-46404 - mappings not showing on query building
// the format of the response depends on the esversion. we have v7 , seems to, which requires the _doc.
const properties = mappings.properties || mappings._doc.properties;
getFieldsRecursively(properties);
}
}
Expand Down Expand Up @@ -1029,6 +1031,7 @@ export class ElasticDatasource
}

private getDatabaseVersionUncached(): Promise<SemVer | null> {
return Promise.resolve(null); // LOGZ.IO GRAFANA CHANGE :: DEV-46435-grafana-10-error-500-on-get-api-datasources-uid-uid-resources
// we want this function to never fail
const getDbVersionObservable = config.featureToggles.enableElasticsearchBackendQuerying
? from(this.getResourceRequest(''))
Expand Down
6 changes: 4 additions & 2 deletions public/app/plugins/datasource/prometheus/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,10 @@ export class PrometheusDatasource

async loadRules() {
try {
const res = await this.metadataRequest('/api/v1/rules', {}, { showErrorAlert: false });
const groups = res.data?.data?.groups;
// LOGZ.IO GRAFANA CHANGE :: DEV-46445-disable-recording-rules-fetch-in-grafana-10
// const res = await this.metadataRequest('/api/v1/rules', {}, { showErrorAlert: false });
// const groups = res.data?.data?.groups;
const groups = null;

if (groups) {
this.ruleMappings = extractRuleMappingFromGroups(groups);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ function guessMetricFamily(metric: string): string {
* @returns true if the LLM plugin is enabled.
*/
export async function isLLMPluginEnabled(): Promise<boolean> {
return Promise.resolve(false); // LOGZ.IO GRAFANA CHANGE :: DEV-44665-grafana-upgrade-remove-llm
// Check if the LLM plugin is enabled.
// If not, we won't be able to make requests, so return early.
const openaiEnabled = llms.openai.health().then((response) => response.ok);
Expand Down
12 changes: 10 additions & 2 deletions public/app/plugins/panel/alertGroups/AlertGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ export const AlertGroup = ({ alertManagerSourceName, group, expandAll }: Props)
end: Date.now(),
});

// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button"
const generatorURL = alert.generatorURL ? (() => {
const url = new URL(alert.generatorURL);
return url.hash.replace(/^#.dashboard.metrics/, '/grafana-app');
})() : null;
// LOGZ.IO CHANGE :: DEV-46517 - fix "see source button" end

return (
<div data-testid={'alert-group-alert'} className={styles.alert} key={`${alert.fingerprint}-${index}`}>
<div>
Expand Down Expand Up @@ -75,8 +82,9 @@ export const AlertGroup = ({ alertManagerSourceName, group, expandAll }: Props)
Silence
</LinkButton>
)}
{alert.generatorURL && (
<LinkButton className={styles.button} href={alert.generatorURL} icon={'chart-line'} size={'sm'}>
{ /* LOGZ.IO CHANGE :: DEV-46517 - patch the link url to work inside iframe */ }
{generatorURL && (
<LinkButton className={styles.button} href={generatorURL} icon={'chart-line'} size={'sm'}>
See source
</LinkButton>
)}
Expand Down

0 comments on commit 9c1dcf3

Please sign in to comment.