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

fix: database name in every table name #405

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions qryn_bun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import handlerDelGroup from './lib/handlers/alerts/del_group.js'
import handlerDelNS from './lib/handlers/alerts/del_ns.js'
import handlerPromGetRules from './lib/handlers/alerts/prom_get_rules.js'
import handlerTail from './lib/handlers/tail.js'
import handlerTempoLabelV2 from './lib/handlers/tempo_v2_tags.js'
import handlerTempoLabelV2Values from './lib/handlers/tempo_v2_values.js'

import { readonly } from './common.js'
import DATABASE, { init } from './lib/db/clickhouse.js'
Expand Down Expand Up @@ -312,6 +314,11 @@ export default async() => {
'*': otlpPushProtoParser
})

fastify.get('/api/v2/search/tags', handlerTempoLabelV2)
fastify.get('/tempo/api/v2/search/tags', handlerTempoLabelV2)
fastify.get('/api/v2/search/tag/:name/values', handlerTempoLabelV2Values)
fastify.get('/tempo/api/v2/search/tag/:name/values', handlerTempoLabelV2Values)

const serveView = fs.existsSync(path.join(__dirname, 'view/index.html'))
if (serveView) {
app.plug(group(path.join(__dirname, 'view')));
Expand Down
22 changes: 12 additions & 10 deletions traceql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { clusterName } = require('../common')
const { DATABASE_NAME } = require('../lib/utils')
const dist = clusterName ? '_dist' : ''
const { rawRequest } = require('../lib/db/clickhouse')
const logger = require('../lib/logger')

/**
*
Expand All @@ -13,6 +14,7 @@ const { rawRequest } = require('../lib/db/clickhouse')
* @returns {Promise<[]>}
*/
const search = async (query, limit, from, to) => {
const _dbname = '`' + DATABASE_NAME() + '`'
const request = {
Request: query,
Ctx: {
Expand All @@ -22,19 +24,19 @@ const search = async (query, limit, from, to) => {
ToS: Math.floor(to.getTime() / 1000),
Limit: parseInt(limit),

TimeSeriesGinTableName: 'time_series_gin',
SamplesTableName: `samples_v3${dist}`,
TimeSeriesTableName: 'time_series',
TimeSeriesDistTableName: 'time_series_dist',
Metrics15sTableName: `metrics_15s${dist}`,
TimeSeriesGinTableName: `${_dbname}.time_series_gin`,
SamplesTableName: `${_dbname}.samples_v3${dist}`,
TimeSeriesTableName: `${_dbname}.time_series`,
TimeSeriesDistTableName: `${_dbname}.time_series_dist`,
Metrics15sTableName: `${_dbname}.metrics_15s${dist}`,

TracesAttrsTable: 'tempo_traces_attrs_gin',
TracesAttrsDistTable: 'tempo_traces_attrs_gin_dist',
TracesTable: 'tempo_traces',
TracesDistTable: 'tempo_traces_dist'
TracesAttrsTable: `${_dbname}.tempo_traces_attrs_gin`,
TracesAttrsDistTable: `${_dbname}.tempo_traces_attrs_gin_dist`,
TracesTable: `${_dbname}.tempo_traces`,
TracesDistTable: `${_dbname}.tempo_traces_dist`
}
}
console.log(JSON.stringify(request))
logger.debug(JSON.stringify(request))
const sql = TranspileTraceQL(request)
const response = await rawRequest(sql + ' FORMAT JSON', null, DATABASE_NAME())
const traces = response.data.data.map(row => ({
Expand Down
Loading