Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <joe@cloudeteer.de>
  • Loading branch information
jkroepke committed Aug 21, 2024
1 parent 797fbf4 commit 7eaf058
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .ci/config/plain/app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: 1

apps:
- type: cloudeteer-dashboardreporter-app
- type: cloudeteer-pdfreport-app
org_id: 1
org_name: Main Org.
disabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ci/config/tls/app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: 1

apps:
- type: cloudeteer-dashboardreporter-app
- type: cloudeteer-pdfreport-app
org_id: 1
org_name: Main Org.
disabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ci/dashboards/static-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"title": "Report",
"tooltip": "Create a PDF report",
"type": "link",
"url": "/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=fdlwjnyim1la8f"
"url": "/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=fdlwjnyim1la8f"
}
],
"liveNow": false,
Expand Down
10 changes: 5 additions & 5 deletions .ci/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.0'
services:
grafana_plain:
# image: grafana/grafana:latest
container_name: 'cloudeteer-dashboardreporter-app-plain'
container_name: 'cloudeteer-pdfreport-app-plain'
build:
context: ../.config
args:
Expand All @@ -12,7 +12,7 @@ services:
ports:
- 3080:${GF_SERVER_HTTP_PORT:-3000}/tcp
volumes:
- ../dist:/var/lib/grafana/plugins/cloudeteer-dashboardreporter-app
- ../dist:/var/lib/grafana/plugins/cloudeteer-pdfreport-app
- ./dashboards:/etc/grafana/provisioning/dashboards
# Dont set config in provisioning just to ensure that plugin works without any
# extra config
Expand Down Expand Up @@ -42,7 +42,7 @@ services:
- GF_RENDERING_SERVER_URL=http://renderer_plain:8081/render
- GF_RENDERING_CALLBACK_URL=http://grafana_plain:${GF_SERVER_HTTP_PORT:-3000}/
- GF_RENDERER_PLUGIN_IGNORE_HTTPS_ERRORS=true
- "GF_LOG_FILTERS=rendering:debug plugin.cloudeteer-dashboardreporter-app:debug"
- "GF_LOG_FILTERS=rendering:debug plugin.cloudeteer-pdfreport-app:debug"
# Set CI mode to remove header in report
- __REPORTER_APP_CI_MODE=true
- GF_REPORTER_PLUGIN_REMOTE_CHROME_URL=${GF_REPORTER_PLUGIN_REMOTE_CHROME_URL:-}
Expand All @@ -66,7 +66,7 @@ services:

grafana_tls:
# image: grafana/grafana:latest
container_name: 'cloudeteer-dashboardreporter-app-tls'
container_name: 'cloudeteer-pdfreport-app-tls'
build:
context: ../.config
args:
Expand All @@ -75,7 +75,7 @@ services:
ports:
- 3443:${GF_SERVER_HTTP_PORT:-3000}/tcp
volumes:
- ../dist:/var/lib/grafana/plugins/cloudeteer-dashboardreporter-app
- ../dist:/var/lib/grafana/plugins/cloudeteer-pdfreport-app
- ./dashboards:/etc/grafana/provisioning/dashboards
- ./config/tls:/etc/grafana/provisioning/plugins
- ./certs:/etc/grafana/tls
Expand Down
2 changes: 1 addition & 1 deletion .config/.cprc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "5.2.2"
"version": "5.3.0"
}
6 changes: 2 additions & 4 deletions .config/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ARG grafana_version=latest
ARG grafana_image=grafana-oss
ARG grafana_image=grafana-enterprise

FROM grafana/${grafana_image}:${grafana_version}

ARG development=false
ARG TARGETARCH

ARG GO_VERSION=1.22.5
ARG GO_VERSION=1.21.6
ARG GO_ARCH=${TARGETARCH:-amd64}

ENV DEV "${development}"
Expand All @@ -27,8 +27,6 @@ WORKDIR $GF_PATHS_HOME

USER root

RUN apk add chromium

# Installing supervisor and inotify-tools
RUN if [ "${development}" = "true" ]; then \
if grep -i -q alpine /etc/issue; then \
Expand Down
2 changes: 1 addition & 1 deletion .config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ services:
grafana_image: ${GRAFANA_IMAGE:-grafana}
```
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker-compose commands, which might be convenient in some scenarios.
In this example, we assign the environment variable `GRAFANA_IMAGE` to the build arg `grafana_image` with a default value of `grafana`. This will allow you to set the value while running the docker compose commands, which might be convenient in some scenarios.

---
8 changes: 4 additions & 4 deletions .config/supervisord/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ user=root
[program:grafana]
user=root
directory=/var/lib/grafana
command=bash -c 'while [ ! -f /root/cloudeteer-dashboardreporter-app/dist/gpx_dashboardreporter-app* ]; do sleep 1; done; /run.sh'
command=bash -c 'while [ ! -f /root/cloudeteer-pdfreport-app/dist/gpx_dashboardreporter-app* ]; do sleep 1; done; /run.sh'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand All @@ -26,7 +26,7 @@ autorestart=true

[program:build-watcher]
user=root
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/cloudeteer-dashboardreporter-app; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
command=/bin/bash -c 'while inotifywait -e modify,create,delete -r /var/lib/grafana/plugins/cloudeteer-pdfreport-app; do echo "Change detected, restarting delve...";supervisorctl restart delve; done'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand All @@ -37,8 +37,8 @@ autostart=true
[program:mage-watcher]
user=root
environment=PATH="/usr/local/go/bin:/root/go/bin:%(ENV_PATH)s"
directory=/root/cloudeteer-dashboardreporter-app
command=/bin/bash -c 'git config --global --add safe.directory /root/cloudeteer-dashboardreporter-app && mage -v watch'
directory=/root/cloudeteer-pdfreport-app
command=/bin/bash -c 'git config --global --add safe.directory /root/cloudeteer-pdfreport-app && mage -v watch'
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
jq '. += {"version":"'"${GITHUB_REF_NAME/v}"'"}' package.json > package.tmp.json
jq '.scripts += {"sign":"npx --yes @grafana/sign-plugin@latest --rootUrls https://opsstack-grafana.test,https://deepview.10010.opsstack.io,https://deepview.10011.opsstack.io,https://deepview.10012.opsstack.io,https://deepview.10013.opsstack.io,https://deepview.10014.opsstack.io,https://deepview.10015.opsstack.io,https://deepview.10016.opsstack.io,https://deepview.10017.opsstack.io,https://deepview.10018.opsstack.io,https://deepview.10019.opsstack.io,https://deepview.10020.opsstack.io,https://deepview.10021.opsstack.io,https://deepview.10022.opsstack.io,https://deepview.10023.opsstack.io,https://deepview.10024.opsstack.io,https://deepview.10025.opsstack.io,https://deepview.10026.opsstack.io,https://deepview.10027.opsstack.io,https://deepview.10028.opsstack.io,https://deepview.10029.opsstack.io,https://deepview.10030.opsstack.io,https://deepview.10031.opsstack.io,https://deepview.10032.opsstack.io,https://deepview.10033.opsstack.io,https://deepview.10034.opsstack.io,https://deepview.10035.opsstack.io,https://deepview.10036.opsstack.io,https://deepview.10037.opsstack.io,https://deepview.10038.opsstack.io,https://deepview.10039.opsstack.io,https://deepview.10040.opsstack.io,https://deepview.10041.opsstack.io,https://deepview.10042.opsstack.io,https://deepview.10043.opsstack.io,https://deepview.10044.opsstack.io,https://deepview.10045.opsstack.io,https://deepview.10046.opsstack.io,https://deepview.10047.opsstack.io,https://deepview.10048.opsstack.io,https://deepview.10049.opsstack.io,https://deepview.10050.opsstack.io,https://deepview.10051.opsstack.io,https://deepview.10052.opsstack.io,https://deepview.10053.opsstack.io,https://deepview.10054.opsstack.io,https://deepview.10055.opsstack.io,https://deepview.10056.opsstack.io,https://deepview.10057.opsstack.io,https://deepview.10058.opsstack.io,https://deepview.10059.opsstack.io,https://deepview.10060.opsstack.io,https://deepview.10061.opsstack.io,https://deepview.10062.opsstack.io,https://deepview.10063.opsstack.io,https://deepview.10064.opsstack.io,https://deepview.10065.opsstack.io,https://deepview.10066.opsstack.io,https://deepview.10067.opsstack.io,https://deepview.10068.opsstack.io,https://deepview.10069.opsstack.io,https://deepview.10070.opsstack.io,https://deepview.10071.opsstack.io,https://deepview.10072.opsstack.io,https://deepview.10073.opsstack.io,https://deepview.10074.opsstack.io,https://deepview.10075.opsstack.io,https://deepview.10076.opsstack.io,https://deepview.10077.opsstack.io,https://deepview.10078.opsstack.io,https://deepview.10079.opsstack.io,https://deepview.10080.opsstack.io,https://deepview.10081.opsstack.io,https://deepview.10082.opsstack.io,https://deepview.10083.opsstack.io,https://deepview.10084.opsstack.io,https://deepview.10085.opsstack.io,https://deepview.10086.opsstack.io,https://deepview.10087.opsstack.io,https://deepview.10088.opsstack.io,https://deepview.10089.opsstack.io,https://deepview.10090.opsstack.io,https://deepview.10091.opsstack.io,https://deepview.10092.opsstack.io,https://deepview.10093.opsstack.io,https://deepview.10094.opsstack.io,https://deepview.10095.opsstack.io,https://deepview.10096.opsstack.io,https://deepview.10097.opsstack.io,https://deepview.10098.opsstack.io,https://deepview.10099.opsstack.io,https://deepview.10100.opsstack.io,https://deepview.cdt.opsstack.io,https://deepview.cdt.dev.opsstack.io,https://deepview.jok.local.opsstack.io,https://deepview.chris.local.opsstack.io,https://deepview.nr.local.opsstack.io"}' package.tmp.json > package.json
find pkg -type f -print0 | xargs -0 sed -i 's/cloudeteer-dashboardreporter-app/cloudeteer-dashboardreporter-app/g'
find src -type f -print0 | xargs -0 sed -i 's/cloudeteer-dashboardreporter-app/cloudeteer-dashboardreporter-app/g'
find pkg -type f -print0 | xargs -0 sed -i 's/cloudeteer-pdfreport-app/cloudeteer-pdfreport-app/g'
find src -type f -print0 | xargs -0 sed -i 's/cloudeteer-pdfreport-app/cloudeteer-pdfreport-app/g'
- uses: grafana/plugin-actions/build-plugin@0315492b375faa7af0fa6c226ecb6c93c6fe9745 # commit of 2024-07-08
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/step_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
# Add +x bits on executables
chmod -R +x dist/gpx_*
mv dist cloudeteer-dashboardreporter-app
zip cloudeteer-dashboardreporter-app-nightly.zip cloudeteer-dashboardreporter-app -r
sha1sum cloudeteer-dashboardreporter-app-nightly.zip | cut -f1 -d' ' > cloudeteer-dashboardreporter-app-nightly.zip.sha1
mv dist cloudeteer-pdfreport-app
zip cloudeteer-pdfreport-app-nightly.zip cloudeteer-pdfreport-app -r
sha1sum cloudeteer-pdfreport-app-nightly.zip | cut -f1 -d' ' > cloudeteer-pdfreport-app-nightly.zip.sha1
- name: Validate plugin
run: |
Expand All @@ -43,7 +43,7 @@ jobs:
pushd ./plugin-validator/pkg/cmd/plugincheck2
go install
popd
plugincheck2 -sourceCodeUri plugin-app.zip -config ./plugin-validator/config/pipeline.yaml cloudeteer-dashboardreporter-app-nightly.zip
plugincheck2 -sourceCodeUri plugin-app.zip -config ./plugin-validator/config/pipeline.yaml cloudeteer-pdfreport-app-nightly.zip
shell: bash

# Check if bootstrap script is working for latest release and nightly release
Expand All @@ -65,8 +65,8 @@ jobs:
with:
name: plugin-artifacts
path: |
cloudeteer-dashboardreporter-app-nightly.zip
cloudeteer-dashboardreporter-app-nightly.zip.sha1
cloudeteer-pdfreport-app-nightly.zip
cloudeteer-pdfreport-app-nightly.zip.sha1
retention-days: 3

- name: Release nightly
Expand All @@ -78,8 +78,8 @@ jobs:
name: nightly
tag_name: nightly
files: |
cloudeteer-dashboardreporter-app-nightly.zip
cloudeteer-dashboardreporter-app-nightly.zip.sha1
cloudeteer-pdfreport-app-nightly.zip
cloudeteer-pdfreport-app-nightly.zip.sha1
fail_on_unmatched_files: true
body: |
# Latest Build Complete! :rocket:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ci/
e2e-results/
**/cypress/videos
**/cypress/report.json
cloudeteer-dashboardreporter-app*
cloudeteer-pdfreport-app*

# Editor
.idea
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ as an unsigned plugin. The installation procedure is briefed in
Download the [latest Grafana Dashboard Reporter](https://github.com/cloudeteer/grafana-pdf-report-app/releases/latest).

Create a directory for grafana to access your custom-plugins
_e.g._ `/var/lib/grafana/plugins/cloudeteer-dashboardreporter-app`.
_e.g._ `/var/lib/grafana/plugins/cloudeteer-pdfreport-app`.

The following shell script downloads and extracts the latest plugin source
code into the the current working directory. Run the following inside your grafana
Expand Down Expand Up @@ -109,15 +109,15 @@ whitelist the plugin, we need to add following to the Grafana configuration file

```ini
[plugins]
allow_loading_unsigned_plugins = cloudeteer-dashboardreporter-app
allow_loading_unsigned_plugins = cloudeteer-pdfreport-app
```

Once this configuration is added, restart the Grafana server and it should load the
plugin. The loading of plugin can be verified by the following log lines

```bash
logger=plugin.signature.validator t=2024-03-21T11:16:54.738077851Z level=warn msg="Permitting unsigned plugin. This is not recommended" pluginID=cloudeteer-dashboardreporter-app
logger=plugin.loader t=2024-03-21T11:16:54.738166325Z level=info msg="Plugin registered" pluginID=cloudeteer-dashboardreporter-app
logger=plugin.signature.validator t=2024-03-21T11:16:54.738077851Z level=warn msg="Permitting unsigned plugin. This is not recommended" pluginID=cloudeteer-pdfreport-app
logger=plugin.loader t=2024-03-21T11:16:54.738166325Z level=info msg="Plugin registered" pluginID=cloudeteer-pdfreport-app

```

Expand All @@ -140,7 +140,7 @@ enable it in different ways.
- From Grafana UI, navigating to `Apps > Dashboard Reporter App > Configuration` will
show [this page](https://github.com/cloudeteer/grafana-pdf-report-app/blob/main/src/img/light.png)
and plugin can be enabled there. The configuration page can also be
accessed by URL `<Grafana URL>/plugins/cloudeteer-dashboardreporter-app`.
accessed by URL `<Grafana URL>/plugins/cloudeteer-pdfreport-app`.

> [!NOTE]
> The warning about `Invalid plugin signature` is not fatal and it is simply saying
Expand Down Expand Up @@ -252,34 +252,34 @@ by using query parameters. It is enough to add query parameters to dashboard rep
to set these values. Currently, the supported query parameters are:

- Query field for theme is `theme` and it takes either `light` or `dark` as value.
Example is `<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&theme=dark`
Example is `<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&theme=dark`

- Query field for layout is `layout` and it takes either `simple` or `grid` as value.
Example is `<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&layout=grid`
Example is `<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&layout=grid`

- Query field for orientation is `orientation` and it takes either `portrait` or `landscape`
as value. Example is `<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&orientation=landscape`
as value. Example is `<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&orientation=landscape`

- Query field for dashboard mode is `dashboardMode` and it takes either `default` or `full`
as value. Example is `<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&dashboardMode=full`
as value. Example is `<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&dashboardMode=full`

- Query field for dashboard mode is `timeZone` and it takes a value in [IANA format](https://www.iana.org/time-zones)
as value. **Note** that it should be encoded to escape URL specific characters. For example
to use `America/New_York` query parameter should be
`<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&timeZone=America%2FNew_York`
`<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&timeZone=America%2FNew_York`

Besides there are two special query parameters available namely:

- `includePanelID`: This can be used to include only panels with IDs set in the query in
the generated report. An example can be
`<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&includePanelID=1&includePanelID=5&includePanelID=8`.
`<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&includePanelID=1&includePanelID=5&includePanelID=8`.
This request will only include the panels `1`, `5` and `8` in the report and ignoring the rest.
When `grid` layout is used with `includePanelID`, the report layout will leave the gaps
in the place of panels that are not included in the report.

- `excludePanelID`: This can be used to exclude any unwanted panels in
the generated report. An example can be
`<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>&excludePanelID=2&excludePanelID=7`.
`<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>&excludePanelID=2&excludePanelID=7`.
This request will only exclude panels `2`, and `7` in the report and including the rest.
When `grid` layout is used with `excludePanelID`, the report layout will leave the gaps
in the place of panels that are excluded in the report.
Expand Down Expand Up @@ -321,7 +321,7 @@ want to create a PDF report. After the user authenticates with Grafana, creating
dashboard report is done by visiting the following end point

```bash
<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>
<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>
```

In addition to `dashUid` query parameter, it is possible to pass time range query
Expand All @@ -338,7 +338,7 @@ Following steps will configure a dashboard link to create PDF report for that da
- Go to Settings of Dashboard
- Go to Links in the side bar and click on `Add Dashboard Link`
- Use Report for `Title` field, set `Type` to `Link`
- Now set `URL` to `<grafanaAppUrl>/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>`
- Now set `URL` to `<grafanaAppUrl>/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>`
- Set `Tooltip` to `Create a PDF report` and set `Icon` to `doc`
- By checking `Include current time range` and `Include current template variables values`,
time range and dashboard variables will be added to query parameters while creating
Expand All @@ -361,7 +361,7 @@ either the same or another API token must be added to the
generated and configured in the plugin, reports can be created using

```bash
curl --output=report.pdf -H "Authorization: Bearer <supersecrettoken>" "https://example.grafana.com/api/plugins/cloudeteer-dashboardreporter-app/resources/report?dashUid=<UID of dashboard>"
curl --output=report.pdf -H "Authorization: Bearer <supersecrettoken>" "https://example.grafana.com/api/plugins/cloudeteer-pdfreport-app/resources/report?dashUid=<UID of dashboard>"
```

The above example shows on how to generate report using `curl` but this can be done with
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
grafana:
# image: grafana/grafana:latest
container_name: 'cloudeteer-dashboardreporter-app'
container_name: 'cloudeteer-pdfreport-app'
build:
context: ./.config
args:
Expand All @@ -17,9 +17,9 @@ services:
- "apparmor:unconfined"
- "seccomp:unconfined"
volumes:
- ./dist:/var/lib/grafana/plugins/cloudeteer-dashboardreporter-app
- ./dist:/var/lib/grafana/plugins/cloudeteer-pdfreport-app
- ./provisioning:/etc/grafana/provisioning
- ./:/root/cloudeteer-dashboardreporter-app
- ./:/root/cloudeteer-pdfreport-app
environment:
# basic settings
# output to terminal
Expand All @@ -44,7 +44,7 @@ services:
# Grafana image renderer
- GF_RENDERING_SERVER_URL=http://renderer:8081/render
- GF_RENDERING_CALLBACK_URL=http://grafana:${GF_SERVER_HTTP_PORT:-3000}/
- "GF_LOG_FILTERS=rendering:debug plugin.cloudeteer-dashboardreporter-app:debug"
- "GF_LOG_FILTERS=rendering:debug plugin.cloudeteer-pdfreport-app:debug"
renderer:
image: grafana/grafana-image-renderer:latest
environment:
Expand Down
Loading

0 comments on commit 7eaf058

Please sign in to comment.