Browse Source

clickhouse 密码配置

dev
巴林闲侠 2 years ago
parent
commit
4e0420ae1d
  1. 2
      api/.vscode/launch.json
  2. 9
      api/app/lib/controllers/alarm/app.js
  3. 6
      api/app/lib/service/clickHouseClient.js
  4. 4
      api/config.js

2
api/.vscode/launch.json

@ -34,6 +34,8 @@
"--clickHouseUrl http://10.8.30.161",
// "--clickHouseUrl https://clickhouse01.anxinyun.cn/play",
"--clickHousePort 30123",
"--clickHouseUser ",
"--clickHousePassword ",
"--clickHouseAnxincloud Anxinyun8",
"--clickHousePepEmis pepca8",
"--clickHouseProjectManage peppm8",

9
api/app/lib/controllers/alarm/app.js

@ -210,8 +210,9 @@ async function apiErrorList (ctx) {
}]
}]
}
let projectRes = []
if (keyword) {
const projectRes = await clickHouse.projectManage.query(`
projectRes = await clickHouse.projectManage.query(`
${pepProjectSql}
WHERE project_name LIKE '%${keyword}%'`
).toPromise()
@ -221,7 +222,7 @@ async function apiErrorList (ctx) {
'$projectApp.projectCorrelation.pep_project_id$': {
$in: projectRes.map(p => p.id)
},
'$projectApp.name$':{$like:`%${keyword}%`}
'$projectApp.name$': { $like: `%${keyword}%` }
}
)
}
@ -264,6 +265,10 @@ async function apiErrorList (ctx) {
const listRes = await models.AppAlarm.findAndCountAll(findOption)
if (!keyword) {
// 没有关键字筛选 查询关联的项目信息
let pepProjectIds = new Set()
for(let lr of listRes){
}
}
ctx.status = 200;

6
api/app/lib/service/clickHouseClient.js

@ -5,7 +5,7 @@ function factory (app, opts) {
if (opts.clickHouse) {
try {
app.fs.clickHouse = {}
const { url, port, db = [] } = opts.clickHouse
const { url, port, user, password, db = [] } = opts.clickHouse
for (let d of db) {
if (d.name && d.db) {
app.fs.clickHouse[d.name] = new ClickHouse({
@ -13,6 +13,10 @@ function factory (app, opts) {
port: port,
debug: opts.dev,
format: "json",
basicAuth: user && password ? {
username: user,
password: password,
} : null,
config: {
database: d.db,
},

4
api/config.js

@ -69,6 +69,8 @@ const QINIU_SK = process.env.ANXINCLOUD_QINIU_SECRETKEY || flags.qnsk;
// clickHouse
const CLICKHOUST_URL = process.env.CLICKHOUST_URL || flags.clickHouseUrl
const CLICKHOUST_PORT = process.env.CLICKHOUST_PORT || flags.clickHousePort
const CLICKHOUST_USER = process.env.CLICKHOUST_USER || flags.clickHouseUser
const CLICKHOUST_PASSWORD = process.env.CLICKHOUST_PASSWORD || flags.clickHousePassword
const CLICKHOUST_ANXINCLOUD = process.env.CLICKHOUST_ANXINCLOUD || flags.clickHouseAnxincloud
const CLICKHOUST_PEP_EMIS = process.env.CLICKHOUST_PEP_EMIS || flags.clickHousePepEmis
const CLICKHOUST_PROJECT_MANAGE = process.env.CLICKHOUST_PROJECT_MANAGE || flags.clickHouseProjectManage
@ -155,6 +157,8 @@ const product = {
clickHouse: {
url: CLICKHOUST_URL,
port: CLICKHOUST_PORT,
user: CLICKHOUST_USER,
password: CLICKHOUST_PASSWORD,
db: [{
name: 'anxinyun',
db: CLICKHOUST_ANXINCLOUD

Loading…
Cancel
Save