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: bind prometheus exposer to 0.0.0.0 #525

Merged
merged 1 commit into from
Apr 27, 2020
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
11 changes: 11 additions & 0 deletions scripts/pack_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ copy_file `get_system_lib server aio` ${pack}/bin/`get_system_libname server aio
copy_file `get_system_lib server zstd` ${pack}/bin/`get_system_libname server zstd`
copy_file `get_system_lib server lz4` ${pack}/bin/`get_system_libname server lz4`

DISTRIB_ID=$(cat /etc/*-release | grep DISTRIB_ID | awk -F'=' '{print $2}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the meaning of these code?

Copy link
Contributor Author

@neverchanje neverchanje Apr 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because binary on linux distribution based on Debian Wheezy requires dependencies of icudata, icuuc, icui18n. If I build a binary on Ubuntu18.04, and want to distribute it to other platforms, like linux in docker, I need to include the libraries in my package.

See this: wkhtmltopdf/wkhtmltopdf#2242

DISTRIB_RELEASE=$(cat /etc/*-release | grep DISTRIB_RELEASE | awk -F'=' '{print $2}')
if [ -n "$DISTRIB_ID" ] && [ -n "$DISTRIB_RELEASE" ]; then
if [ "$DISTRIB_ID" == "Ubuntu" ] && [ "$DISTRIB_RELEASE" == "18.04" ]; then
copy_file "$(get_system_lib server icui18n)" "$pack/bin/$(get_system_libname server icui18n)"
copy_file "$(get_system_lib server icuuc)" "$pack/bin/$(get_system_libname server icuuc)"
copy_file "$(get_system_lib server icudata)" "$pack/bin/$(get_system_libname server icudata)"
fi
# more cases can be added here.
fi

chmod +x ${pack}/bin/pegasus_* ${pack}/bin/*.sh
chmod -x ${pack}/bin/lib*

Expand Down
19 changes: 5 additions & 14 deletions src/reporter/pegasus_counter_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <map>
#include <memory>
#include <string>
#include <fmt/format.h>
#include <dsn/dist/fmt_logging.h>

using namespace ::dsn;

Expand All @@ -34,16 +34,6 @@ static std::string get_hostname()
return hostname;
}

static std::string get_hostip()
{
uint32_t ip = dsn::rpc_address::ipv4_from_network_interface("");
uint32_t ipnet = htonl(ip);
char buffer[512];
memset(buffer, 0, sizeof(buffer));
assert(inet_ntop(AF_INET, &ipnet, buffer, sizeof(buffer)));
return buffer;
}

static void format_metrics_name(std::string &metrics_name)
{
replace(metrics_name.begin(), metrics_name.end(), '@', ':');
Expand Down Expand Up @@ -87,12 +77,13 @@ pegasus_counter_reporter::~pegasus_counter_reporter() { stop(); }
void pegasus_counter_reporter::prometheus_initialize()
{
_prometheus_port = (uint16_t)dsn_config_get_value_uint64(
"pegasus.server", "prometheus_port", 9091, "prometheus gateway port");
"pegasus.server", "prometheus_port", 9091, "prometheus exposer port");

_registry = std::make_shared<prometheus::Registry>();
_exposer = dsn::make_unique<prometheus::Exposer>(
fmt::format("{}:{}", get_hostip().c_str(), _prometheus_port));
_exposer = dsn::make_unique<prometheus::Exposer>(fmt::format("0.0.0.0:{}", _prometheus_port));
_exposer->RegisterCollectable(_registry);

ddebug_f("prometheus exposer [0.0.0.0:{}] started", _prometheus_port);
}

void pegasus_counter_reporter::falcon_initialize()
Expand Down