Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connector API for Grafana to automatically connect Grafana to the existing OnCall instance #122

Closed
geowatson opened this issue Jun 21, 2022 · 8 comments
Assignees

Comments

@geowatson
Copy link
Contributor

It would be great to automatically connect on-premise Grafana instance during upgrade (via helm etc) to the existing OnCall instance via custom env variables, or config in grafana.ini and config in oncall helm chart.

@Matvey-Kuk
Copy link
Contributor

We added this task to the core team's backlog.

@davidspek
Copy link
Contributor

I believe this could be done with a secret and the plugins sidecar already. For example:

apiVersion: v1
kind: Secret
metadata:
  name: oncall-plugin
  namespace: oncall
  labels:
    grafana_plugin: ""
type: Opaque
stringData:
  oncall-plugin.yaml: |
    apiVersion: 1
    apps:
    - type: grafana-oncall-app
      name: grafana-oncall-app
      disabled: false
      jsonData:
        grafanaUrl: https://grafana.example.com
        onCallApiUrl: https://oncall.example.com
      secureJsonData:
        onCallInvitationToken: xxxx

While this does configure the plugin, I'm getting an error about the token being invalid (It seems like your invite token may be invalid.).

@iskhakov
Copy link
Contributor

@davidspek There is the limitation in current frontend, so we cannot provision the plugin with the token. It will be fixed by in this issue #452 and the auto-provisioning will become possible

@Matvey-Kuk
Copy link
Contributor

#452 is closed so this one is unblocked :)

Copy link
Contributor

github-actions bot commented Nov 8, 2023

This issue has been automatically marked as stale because it has not had activity in the last 120 days.

@github-actions github-actions bot added the pr:stale Added to a PR that has been deemed "stale". Managed by the actions/stale GitHub Action label Nov 8, 2023
@pathakhimanshucs
Copy link

Are there any updates or workaround on this? I believe #3761 refers to somewhat the same issue.

@github-actions github-actions bot removed the pr:stale Added to a PR that has been deemed "stale". Managed by the actions/stale GitHub Action label Mar 22, 2024
@ChristianCiach
Copy link

ChristianCiach commented Jun 3, 2024

According to the changelog, this should already be possible:

https://github.com/grafana/oncall/blob/dev/CHANGELOG.md#v113-2022-11-22

The OnCall API URL can optionally be passed as an environment variable, ONCALL_API_URL, to the OnCall UI. If the environment variable is found, the plugin will "auto-configure", otherwise you will be shown a simple configuration form to provide this info.

But unfortunately this doesn't work. The code in question:

// Single source of truth on the frontend for OnCall API URL
export const getOnCallApiUrl = (meta?: OnCallAppPluginMeta) => {
if (meta?.jsonData?.onCallApiUrl) {
return meta?.jsonData?.onCallApiUrl;
} else if (typeof window === 'undefined') {
return process.env.ONCALL_API_URL;
}
return undefined;
};
// If the plugin has never been configured, onCallApiUrl will be undefined in the plugin's jsonData
export const hasPluginBeenConfigured = (meta?: OnCallAppPluginMeta) => Boolean(meta?.jsonData?.onCallApiUrl);

Contrary to the comment on getOnCallApiUrl, this function is not the "single source of truth", as the hasPluginBeenConfigured just below it references the jsonData directly, thus bypassing the ONCALL_API_URL environment variable.

Edit: Reading the git history, this probably (but I'm not entirely sure) worked fine until commit 92fa509 from PR:

Anyway, I would prefer to have working plugin provisioning via grafana/provisioning/plugins/*.yaml.

@mderynck
Copy link
Contributor

mderynck commented Sep 6, 2024

Recently we made some changes to the way Grafana OnCall is initialized. Use 1.9.22, there were quite a few changes along the way from 1.9.0-1.9.22 to get things working.

  • If you are running Grafana 11 and newer you must have externalServiceAccounts feature toggle enabled.
    This has already been enabled in the docker compose files and helm charts in the oncall repo.
  • Plugin settings must be provided to the plugin using an API call if you are installing for the first time (Note: credentials and hostnames need to be adjusted for your configuration, stackId and orgId are expected to be the listed constants in a self-hosted configuration)
curl -X POST 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/settings' -H "Content-Type: application/json" -d '{"enabled":true, "jsonData":{"stackId":5, "orgId":100, "onCallApiUrl":"http://engine:8080/", "grafanaUrl":"http://grafana:3000/"}}'
  • Once settings are configured use this API call to install:
curl -X POST 'http://admin:admin@localhost:3000/api/plugins/grafana-oncall-app/resources/plugin/install'

Grafana OnCall should now be ready to use.
For additional troubleshooting see here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants