Skip to content

Commit 6f2ce75

Browse files
LLKCoder冯勇蒿@fyh01789115
andauthored
Add TKP service (#135)
* add tkp plugins and dashboard json. Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> * update api url. * bug fix. * format grafana-cm.yaml * update param's name * update cm config and fix bug Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> * remove state. Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> * fix:add tkp action tips. Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> * update: node size and position. Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> * update: set tkp try time to 5. * update: tkp try time. --------- Signed-off-by: 冯勇蒿@fyh01789115 <[email protected]> Co-authored-by: 冯勇蒿@fyh01789115 <[email protected]>
1 parent 59d5107 commit 6f2ce75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+19674
-2
lines changed

.github/workflows/docker-helm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
DOCKERHUB_LUNETTES_REPO: lunettes/lunettes
1212
DOCKERHUB_GRAFANA_REPO: lunettes/grafana
1313
# Plugins to be installed.
14-
GRAFANA_PLUGINS: "yesoreyeram-infinity-datasource,marcusolsson-json-datasource,marcusolsson-dynamictext-panel,volkovlabs-form-panel:3.1.0"
14+
GRAFANA_PLUGINS: "yesoreyeram-infinity-datasource,marcusolsson-json-datasource,marcusolsson-dynamictext-panel,volkovlabs-form-panel:3.1.0,volkovlabs-echarts-panel"
1515

1616

1717
jobs:

build/docker/Dockerfile.grafana

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ WORKDIR /app/filter_panel
1414
# 安装依赖并编译
1515
RUN npm install \
1616
&& npm run build
17+
# 将tkpTable panel代码拷贝到镜像中的工作目录
18+
COPY ./grafana_plugin/tkp_table_panel /app/tkp_table_panel
19+
# 在镜像中创建工作目录
20+
WORKDIR /app/tkp_table_panel
21+
# 安装依赖并编译
22+
RUN npm install && npm run build
1723

1824
# Use the official Grafana image as the base image.
1925
FROM grafana/grafana:10.4.2-ubuntu
2026

2127
COPY --from=node /app/yaml_panel/dist /var/lib/grafana/plugins/antgroup-yaml-panel
2228
COPY --from=node /app/filter_panel/dist /var/lib/grafana/plugins/antgroup-filter-panel
29+
COPY --from=node /app/tkp_table_panel/dist /var/lib/grafana/plugins/antgroup-tkptable-panel
2330

2431
# Define the list of plugins to install, separated by spaces.
2532
ARG PLUGINS=""

deploy/helm/lunettes/templates/grafana/grafana-cm.yaml

Lines changed: 615 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "4.16.2"
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
3+
*
4+
* In order to extend the configuration follow the steps in
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-eslint-config
6+
*/
7+
{
8+
"extends": ["@grafana/eslint-config"],
9+
"root": true,
10+
"rules": {
11+
"react/prop-types": "off"
12+
},
13+
"overrides": [
14+
{
15+
"plugins": ["deprecation"],
16+
"files": ["src/**/*.{ts,tsx}"],
17+
"rules": {
18+
"deprecation/deprecation": "warn"
19+
},
20+
"parserOptions": {
21+
"project": "./tsconfig.json"
22+
}
23+
}
24+
]
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
3+
*
4+
* In order to extend the configuration follow the steps in .config/README.md
5+
*/
6+
7+
module.exports = {
8+
endOfLine: 'auto',
9+
printWidth: 120,
10+
trailingComma: 'es5',
11+
semi: true,
12+
jsxSingleQuote: false,
13+
singleQuote: true,
14+
useTabs: false,
15+
tabWidth: 2,
16+
};
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
ARG grafana_version=latest
2+
ARG grafana_image=grafana-enterprise
3+
4+
FROM grafana/${grafana_image}:${grafana_version}
5+
6+
ARG development=false
7+
ARG TARGETARCH
8+
9+
10+
ENV DEV "${development}"
11+
12+
# Make it as simple as possible to access the grafana instance for development purposes
13+
# Do NOT enable these settings in a public facing / production grafana instance
14+
ENV GF_AUTH_ANONYMOUS_ORG_ROLE "Admin"
15+
ENV GF_AUTH_ANONYMOUS_ENABLED "true"
16+
ENV GF_AUTH_BASIC_ENABLED "false"
17+
# Set development mode so plugins can be loaded without the need to sign
18+
ENV GF_DEFAULT_APP_MODE "development"
19+
20+
21+
LABEL maintainer="Grafana Labs <[email protected]>"
22+
23+
ENV GF_PATHS_HOME="/usr/share/grafana"
24+
WORKDIR $GF_PATHS_HOME
25+
26+
USER root
27+
28+
# Installing supervisor and inotify-tools
29+
RUN if [ "${development}" = "true" ]; then \
30+
if grep -i -q alpine /etc/issue; then \
31+
apk add supervisor inotify-tools git; \
32+
elif grep -i -q ubuntu /etc/issue; then \
33+
DEBIAN_FRONTEND=noninteractive && \
34+
apt-get update && \
35+
apt-get install -y supervisor inotify-tools git && \
36+
rm -rf /var/lib/apt/lists/*; \
37+
else \
38+
echo 'ERROR: Unsupported base image' && /bin/false; \
39+
fi \
40+
fi
41+
42+
COPY supervisord/supervisord.conf /etc/supervisor.d/supervisord.ini
43+
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
44+
45+
46+
47+
# Inject livereload script into grafana index.html
48+
RUN sed -i 's|</body>|<script src="http://localhost:35729/livereload.js"></script></body>|g' /usr/share/grafana/public/views/index.html
49+
50+
51+
COPY entrypoint.sh /entrypoint.sh
52+
RUN chmod +x /entrypoint.sh
53+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Default build configuration by Grafana
2+
3+
**This is an auto-generated directory and is not intended to be changed! ⚠️**
4+
5+
The `.config/` directory holds basic configuration for the different tools
6+
that are used to develop, test and build the project. In order to make it updates easier we ask you to
7+
not edit files in this folder to extend configuration.
8+
9+
## How to extend the basic configs?
10+
11+
Bear in mind that you are doing it at your own risk, and that extending any of the basic configuration can lead
12+
to issues around working with the project.
13+
14+
### Extending the ESLint config
15+
16+
Edit the `.eslintrc` file in the project root in order to extend the ESLint configuration.
17+
18+
**Example:**
19+
20+
```json
21+
{
22+
"extends": "./.config/.eslintrc",
23+
"rules": {
24+
"react/prop-types": "off"
25+
}
26+
}
27+
```
28+
29+
---
30+
31+
### Extending the Prettier config
32+
33+
Edit the `.prettierrc.js` file in the project root in order to extend the Prettier configuration.
34+
35+
**Example:**
36+
37+
```javascript
38+
module.exports = {
39+
// Prettier configuration provided by Grafana scaffolding
40+
...require('./.config/.prettierrc.js'),
41+
42+
semi: false,
43+
};
44+
```
45+
46+
---
47+
48+
### Extending the Jest config
49+
50+
There are two configuration in the project root that belong to Jest: `jest-setup.js` and `jest.config.js`.
51+
52+
**`jest-setup.js`:** A file that is run before each test file in the suite is executed. We are using it to
53+
set up the Jest DOM for the testing library and to apply some polyfills. ([link to Jest docs](https://jestjs.io/docs/configuration#setupfilesafterenv-array))
54+
55+
**`jest.config.js`:** The main Jest configuration file that extends the Grafana recommended setup. ([link to Jest docs](https://jestjs.io/docs/configuration))
56+
57+
#### ESM errors with Jest
58+
59+
A common issue with the current jest config involves importing an npm package that only offers an ESM build. These packages cause jest to error with `SyntaxError: Cannot use import statement outside a module`. To work around this, we provide a list of known packages to pass to the `[transformIgnorePatterns](https://jestjs.io/docs/configuration#transformignorepatterns-arraystring)` jest configuration property. If need be, this can be extended in the following way:
60+
61+
```javascript
62+
process.env.TZ = 'UTC';
63+
const { grafanaESModules, nodeModulesToTransform } = require('./config/jest/utils');
64+
65+
module.exports = {
66+
// Jest configuration provided by Grafana
67+
...require('./.config/jest.config'),
68+
// Inform jest to only transform specific node_module packages.
69+
transformIgnorePatterns: [nodeModulesToTransform([...grafanaESModules, 'packageName'])],
70+
};
71+
```
72+
73+
---
74+
75+
### Extending the TypeScript config
76+
77+
Edit the `tsconfig.json` file in the project root in order to extend the TypeScript configuration.
78+
79+
**Example:**
80+
81+
```json
82+
{
83+
"extends": "./.config/tsconfig.json",
84+
"compilerOptions": {
85+
"preserveConstEnums": true
86+
}
87+
}
88+
```
89+
90+
---
91+
92+
### Extending the Webpack config
93+
94+
Follow these steps to extend the basic Webpack configuration that lives under `.config/`:
95+
96+
#### 1. Create a new Webpack configuration file
97+
98+
Create a new config file that is going to extend the basic one provided by Grafana.
99+
It can live in the project root, e.g. `webpack.config.ts`.
100+
101+
#### 2. Merge the basic config provided by Grafana and your custom setup
102+
103+
We are going to use [`webpack-merge`](https://github.com/survivejs/webpack-merge) for this.
104+
105+
```typescript
106+
// webpack.config.ts
107+
import type { Configuration } from 'webpack';
108+
import { merge } from 'webpack-merge';
109+
import grafanaConfig from './.config/webpack/webpack.config';
110+
111+
const config = async (env): Promise<Configuration> => {
112+
const baseConfig = await grafanaConfig(env);
113+
114+
return merge(baseConfig, {
115+
// Add custom config here...
116+
output: {
117+
asyncChunks: true,
118+
},
119+
});
120+
};
121+
122+
export default config;
123+
```
124+
125+
#### 3. Update the `package.json` to use the new Webpack config
126+
127+
We need to update the `scripts` in the `package.json` to use the extended Webpack configuration.
128+
129+
**Update for `build`:**
130+
131+
```diff
132+
-"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
133+
+"build": "webpack -c ./webpack.config.ts --env production",
134+
```
135+
136+
**Update for `dev`:**
137+
138+
```diff
139+
-"dev": "webpack -w -c ./.config/webpack/webpack.config.ts --env development",
140+
+"dev": "webpack -w -c ./webpack.config.ts --env development",
141+
```
142+
143+
### Configure grafana image to use when running docker
144+
145+
By default, `grafana-enterprise` will be used as the docker image for all docker related commands. If you want to override this behavior, simply alter the `docker-compose.yaml` by adding the following build arg `grafana_image`.
146+
147+
**Example:**
148+
149+
```yaml
150+
version: '3.7'
151+
152+
services:
153+
grafana:
154+
container_name: 'myorg-basic-app'
155+
build:
156+
context: ./.config
157+
args:
158+
grafana_version: ${GRAFANA_VERSION:-9.1.2}
159+
grafana_image: ${GRAFANA_IMAGE:-grafana}
160+
```
161+
162+
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.
163+
164+
---
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
if [ "${DEV}" = "false" ]; then
4+
echo "Starting test mode"
5+
exec /run.sh
6+
fi
7+
8+
echo "Starting development mode"
9+
10+
if grep -i -q alpine /etc/issue; then
11+
exec /usr/bin/supervisord -c /etc/supervisord.conf
12+
elif grep -i -q ubuntu /etc/issue; then
13+
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
14+
else
15+
echo 'ERROR: Unsupported base image'
16+
exit 1
17+
fi
18+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
3+
*
4+
* In order to extend the configuration follow the steps in
5+
* https://grafana.com/developers/plugin-tools/create-a-plugin/extend-a-plugin/extend-configurations#extend-the-jest-config
6+
*/
7+
8+
import '@testing-library/jest-dom';
9+
import { TextEncoder, TextDecoder } from 'util';
10+
11+
Object.assign(global, { TextDecoder, TextEncoder });
12+
13+
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
14+
Object.defineProperty(global, 'matchMedia', {
15+
writable: true,
16+
value: jest.fn().mockImplementation((query) => ({
17+
matches: false,
18+
media: query,
19+
onchange: null,
20+
addListener: jest.fn(), // deprecated
21+
removeListener: jest.fn(), // deprecated
22+
addEventListener: jest.fn(),
23+
removeEventListener: jest.fn(),
24+
dispatchEvent: jest.fn(),
25+
})),
26+
});
27+
28+
HTMLCanvasElement.prototype.getContext = () => {};

0 commit comments

Comments
 (0)