Skip to content

Commit 3a778dd

Browse files
authored
Add clickhouse_cpp bazel repository (#2394)
Summary: Add clickhouse_cpp bazel repository The [k8sstormcenter project](https://github.com/k8sstormcenter/) uses Pixie as a telemetry source (protocol tracing + dynamic tracing w/ bpftrace) for its security operations control, which complements the project’s existing detection and threat intelligence capabilities. k8sstormcenter uses ClickHouse as its central forensic database, where telemetry from multiple security tools is aggregated and correlated. To better integrate Pixie into this architecture, the project extends Pixie with native ClickHouse support, allowing Pixie to: * Read existing security and forensic data stored in ClickHouse. * Correlate Pixie’s runtime telemetry with telemetry from other security data sources. * Persist Pixie-generated telemetry and analysis results directly back into ClickHouse. This is the first PR of a series that implements the functionality explained above. Relevant Issues: N/A Type of change: /kind dep Test Plan: New bazel repository targets build --------- Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent 77e8d9e commit 3a778dd

5 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2018- The Pixie Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
18+
19+
licenses(["notice"])
20+
21+
exports_files(["LICENSE"])
22+
23+
filegroup(
24+
name = "all",
25+
srcs = glob(["**"]),
26+
)
27+
28+
cmake(
29+
name = "clickhouse_cpp",
30+
build_args = [
31+
"--", # <- Pass remaining options to the native tool.
32+
"-j`nproc`",
33+
"-l`nproc`",
34+
],
35+
cache_entries = {
36+
"BUILD_BENCHMARK": "OFF",
37+
"BUILD_TESTS": "OFF",
38+
"BUILD_SHARED_LIBS": "OFF",
39+
"CMAKE_BUILD_TYPE": "Release",
40+
"WITH_OPENSSL": "ON",
41+
"WITH_SYSTEM_ABSEIL": "ON",
42+
"WITH_SYSTEM_LZ4": "OFF",
43+
"WITH_SYSTEM_CITYHASH": "OFF",
44+
"WITH_SYSTEM_ZSTD": "OFF",
45+
"CMAKE_POSITION_INDEPENDENT_CODE": "ON",
46+
},
47+
lib_source = ":all",
48+
out_static_libs = [
49+
"libclickhouse-cpp-lib.a",
50+
"liblz4.a",
51+
"libcityhash.a",
52+
"libzstdstatic.a",
53+
],
54+
targets = [
55+
"clickhouse-cpp-lib",
56+
"lz4",
57+
"cityhash",
58+
"zstdstatic",
59+
],
60+
visibility = ["//visibility:public"],
61+
working_directory = "",
62+
deps = [
63+
"@boringssl//:crypto",
64+
"@boringssl//:ssl",
65+
"@com_google_absl//absl/numeric:int128",
66+
],
67+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/cmake/openssl.cmake b/cmake/openssl.cmake
2+
--- a/cmake/openssl.cmake
3+
+++ b/cmake/openssl.cmake
4+
@@ -3,4 +3,10 @@
5+
IF (WITH_OPENSSL)
6+
- FIND_PACKAGE (OpenSSL REQUIRED)
7+
- ADD_COMPILE_DEFINITIONS (WITH_OPENSSL=1)
8+
+ ADD_LIBRARY (OpenSSL::Crypto INTERFACE IMPORTED GLOBAL)
9+
+ SET_TARGET_PROPERTIES (OpenSSL::Crypto PROPERTIES
10+
+ INTERFACE_INCLUDE_DIRECTORIES "$ENV{EXT_BUILD_ROOT}/external/boringssl/src/include")
11+
+ ADD_LIBRARY (OpenSSL::SSL INTERFACE IMPORTED GLOBAL)
12+
+ SET_TARGET_PROPERTIES (OpenSSL::SSL PROPERTIES
13+
+ INTERFACE_INCLUDE_DIRECTORIES "$ENV{EXT_BUILD_ROOT}/external/boringssl/src/include"
14+
+ INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
15+
+ ADD_COMPILE_DEFINITIONS (WITH_OPENSSL=1 USE_BORINGSSL)
16+
ENDIF ()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
--- a/CMakeLists.txt
3+
+++ b/CMakeLists.txt
4+
@@ -81,6 +81,9 @@
5+
IF (WITH_SYSTEM_ABSEIL)
6+
- FIND_PACKAGE(absl REQUIRED)
7+
+ ADD_LIBRARY (absl::int128 STATIC IMPORTED)
8+
+ SET_TARGET_PROPERTIES (absl::int128 PROPERTIES
9+
+ IMPORTED_LOCATION "$ENV{EXT_BUILD_DEPS}/lib/libint128.a"
10+
+ INTERFACE_INCLUDE_DIRECTORIES "$ENV{EXT_BUILD_ROOT}/external/com_google_absl")
11+
ELSE ()
12+
INCLUDE_DIRECTORIES (contrib/absl)
13+
SUBDIRS (contrib/absl/absl)
14+
ENDIF ()

bazel/repositories.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def _cc_deps():
153153
_bazel_repo("com_github_ariafallah_csv_parser", build_file = "//bazel/external:csv_parser.BUILD")
154154
_bazel_repo("com_github_arun11299_cpp_jwt", build_file = "//bazel/external:cpp_jwt.BUILD")
155155
_bazel_repo("com_github_cameron314_concurrentqueue", build_file = "//bazel/external:concurrentqueue.BUILD")
156+
_bazel_repo("com_github_clickhouse_clickhouse_cpp", build_file = "//bazel/external:clickhouse_cpp.BUILD", patches = ["//bazel/external:clickhouse_cpp_system_abseil.patch", "//bazel/external:clickhouse_cpp_boringssl.patch"], patch_args = ["-p1"])
156157
_bazel_repo("com_github_cyan4973_xxhash", build_file = "//bazel/external:xxhash.BUILD")
157158
_bazel_repo("com_github_nlohmann_json", build_file = "//bazel/external:nlohmann_json.BUILD")
158159
_bazel_repo("com_github_packetzero_dnsparser", build_file = "//bazel/external:dnsparser.BUILD")

bazel/repository_locations.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ REPOSITORY_LOCATIONS = dict(
7676
strip_prefix = "concurrentqueue-1.0.3",
7777
urls = ["https://github.com/cameron314/concurrentqueue/archive/refs/tags/v1.0.3.tar.gz"],
7878
),
79+
com_github_clickhouse_clickhouse_cpp = dict(
80+
sha256 = "bac497857759e991fa4e1638bccf936cb36d10ad79273695a570272cc4891428",
81+
strip_prefix = "clickhouse-cpp-2.6.2",
82+
urls = ["https://github.com/ClickHouse/clickhouse-cpp/archive/refs/tags/v2.6.2.tar.gz"],
83+
),
7984
com_github_cyan4973_xxhash = dict(
8085
sha256 = "952ebbf5b11fbf59ae5d760a562d1e9112278f244340ad7714e8556cbe54f7f7",
8186
strip_prefix = "xxHash-0.7.3",

0 commit comments

Comments
 (0)