-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18800 from rpastrana/HPCC-29546-GrafanaLoki-LogAc…
…cess HPCC-29546 Grafana/loki logaccess plugin Reviewed-by: Gavin Halliday <[email protected]> Merged-by: Gavin Halliday <[email protected]>
- Loading branch information
Showing
14 changed files
with
1,293 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
helm/managed/logging/loki-stack/create-grafana-logaccess-secret.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
WORK_DIR=$(dirname $0) | ||
source ${WORK_DIR}/env-loganalytics | ||
|
||
k8scommand="kubectl" | ||
secretname="grafana-logaccess" | ||
secretsdir="${WORK_DIR}/secrets-templates" | ||
namespace="default" | ||
|
||
usage() | ||
{ | ||
echo "Creates necessary k8s secret used by HPCC's logAccess to access Loki data source through Grafana" | ||
echo "> create-grafana-logaccess-secret.sh [Options]" | ||
echo "" | ||
echo "Options:" | ||
echo "-d Specifies directory containing required secret values in self named files." | ||
echo " Defaults to <workingdir>/<${secretssubdir}>" | ||
echo "-h Print Usage message" | ||
echo "-n Specifies namespace for secret" | ||
echo "" | ||
echo "Requires directory containing secret values in dedicated files." | ||
echo "Defaults to ${secretssubdir} if not specified via -d option." | ||
echo "" | ||
echo "Expected directory structure:" | ||
echo "${secretsdir}/" | ||
echo " password - Should contain Grafana user name" | ||
echo " username - Should contain Grafana password" | ||
} | ||
|
||
while [ "$#" -gt 0 ]; do | ||
arg=$1 | ||
case "${arg}" in | ||
-h) | ||
usage | ||
exit | ||
;; | ||
-d) shift | ||
secretsdir=$1 | ||
;; | ||
-n) shift | ||
namespace=$1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
echo "Creating '${namespace}/${secretname}' secret." | ||
|
||
command -v ${k8scommand} >/dev/null 2>&1 || { echo >&2 "Aborting - '${k8scommand}' not found!"; exit 1; } | ||
|
||
errormessage=$(${k8scommand} get secret ${secretname} -n ${namespace} 2>&1) | ||
if [[ $? -eq 0 ]] | ||
then | ||
echo "WARNING: Target secret '${namespace}/${secretname}' already exists! Delete it and re-run if secret update desired." | ||
echo "${errormessage}" | ||
exit 1 | ||
fi | ||
|
||
errormessage=$(${k8scommand} create secret generic ${secretname} --from-file=${secretsdir} -n ${namespace} ) | ||
if [[ $? -ne 0 ]] | ||
then | ||
echo "Error creating: Target secret '${namespace}/${secretname}'!" | ||
echo >&2 | ||
usage | ||
exit 1 | ||
else | ||
echo "Target secret '${namespace}/${secretname}' successfully created!" | ||
${k8scommand} get secret ${secretname} -n ${namespace} | ||
fi |
43 changes: 43 additions & 0 deletions
43
helm/managed/logging/loki-stack/grafana-hpcc-logaccess.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Configures HPCC logAccess to target grafana/loki | ||
global: | ||
logAccess: | ||
name: "Grafana/loki stack log access" | ||
type: "GrafanaCurl" | ||
connection: | ||
protocol: "http" | ||
host: "myloki4hpcclogs-grafana.default.svc.cluster.local" | ||
port: 3000 | ||
datasource: | ||
id: "1" | ||
name: "Loki" | ||
namespace: | ||
name: "hpcc" | ||
logFormat: | ||
type: "json" | ||
logMaps: | ||
- type: "global" | ||
searchColumn: "log" | ||
columnMode: "DEFAULT" | ||
- type: "components" | ||
storeName: "stream" | ||
searchColumn: "component" | ||
columnMode: "MIN" | ||
columnType: "string" | ||
- type: "timestamp" | ||
storeName: "values" | ||
searchColumn: "time" | ||
columnMode: "ALL" | ||
columnType: "datetime" | ||
- type: "pod" | ||
storeName: "stream" | ||
searchColumn: "pod" | ||
columnMode: "ALL" | ||
columnType: "string" | ||
secrets: | ||
esp: | ||
grafana-logaccess: "grafana-logaccess" | ||
vaults: | ||
esp: | ||
- name: my-grafana-logaccess-vault | ||
url: http://${env.VAULT_SERVICE_HOST}:${env.VAULT_SERVICE_PORT}/v1/secret/data/esp/${secret} | ||
kind: kv-v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<Grafana access password goes here> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
############################################################################### | ||
# HPCC SYSTEMS software Copyright (C) 2022 HPCC Systems®. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
IF(NOT CLIENTTOOLS_ONLY) | ||
HPCC_ADD_SUBDIRECTORY (CurlClient) | ||
ENDIF() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
############################################################################### | ||
# HPCC SYSTEMS software Copyright (C) 2022 HPCC Systems®. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
################################################################################ | ||
|
||
project(GrafanaCurllogaccess) | ||
|
||
# Required installed libraries | ||
find_package(CURL REQUIRED) | ||
|
||
set(srcs | ||
${CMAKE_CURRENT_SOURCE_DIR}/GrafanaCurlClient.cpp | ||
) | ||
|
||
include_directories( | ||
${HPCC_SOURCE_DIR}/system/include | ||
${HPCC_SOURCE_DIR}/system/jlib | ||
${CURL_INCLUDE_DIR} | ||
) | ||
|
||
add_definitions(-DGRAFANA_CURL_LOGACCESS_EXPORTS) | ||
|
||
HPCC_ADD_LIBRARY(${PROJECT_NAME} SHARED ${srcs}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
PRIVATE jlib | ||
PRIVATE ${CURL_LIBRARIES} | ||
) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
RUNTIME DESTINATION ${EXEC_DIR} | ||
LIBRARY DESTINATION ${LIB_DIR} | ||
CALC_DEPS | ||
) |
Oops, something went wrong.