Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement Skywalking to support HTTP 1.1 Communication Interface

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge about "how to implement Skywalking to support HTTP 1.1 communication interface". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

What is OpenResty?

OpenResty is a high-performance Web platform based on Nginx and Lua, which integrates a large number of sophisticated Lua libraries, third-party modules and most dependencies. It is used to easily build dynamic Web applications, Web services and dynamic gateways that can handle ultra-high concurrency and high scalability.

Therefore, many companies use OpenResty to develop high-performance web Server modules suitable for their own business.

So what does it care about Skywalking? Skywalking is an APM system developed in Java that monitors the call links between services and service application metrics. An application performance monitoring tool for distributed systems, designed for microservices, cloud-native architectures, and container-based (Docker, K8s, Mesos) architectures.

Suppose, when we use Nginx/OpenResty to do Load Balancer for our microservices, how can we string the whole link through the request, and how to ensure that the topology of the whole link is correct? The current solution is to support link information reporting in Nginx, and at the same time be able to pass the key information of the requested link to the upstream application.

Skywalking 7.x supports HTTP 1.1

Skywalking monitors Java, Golang, Node, and. NET language links by using SDK or Agent to report data to Skywalking backend. Apache Nginx Lua considers that Nginx is sufficient for more than 10K concurrent connection responses, and does not use Nginx gRPC, so Skywalking is required to support HTTP 1.1 communication interfaces.

How do you play?

Here's a logic diagram of how to play:

skywalking_nginx_lua

First install Openrest refer to official website: openresty.org/cn/download.html

Macos system installed with Homebrew:

> brew install openresty/brew/openresty

==> Summary

???? /usr/local/Cellar/openresty/1.15.8.2: 303 files, 6.5MB, built in 1 minute

==> Caveats

==> openresty-openssl

openresty-openssl is keg-only, which means it was not symlinked into /usr/local,

because only for use with OpenResty.

If you need to have openresty-openssl first in your PATH run:

echo 'export PATH="/usr/local/opt/openresty-openssl/bin:$PATH"' >> ~/.zshrc

For compilers to find openresty-openssl you may need to set:

export LDFLAGS="-L/usr/local/opt/openresty-openssl/lib"

export CPPFLAGS="-I/usr/local/opt/openresty-openssl/include"

==> openresty

To have launchd start openresty/brew/openresty now and restart at login:

brew services start openresty/brew/openresty

Or, if you don't want/need a background service you can just run:

openresty

Clone or download Apache Nginx Lua library git clone https://github.com/apache/skywalking-nginx-lua.git

cd skywalking-nginx-lua/examples/

This directory stores sample configurations for Nginx, some of which are as follows:

nginx.conf:http {

#This points to the newly cloned skywalking nginx lua project

lua_package_path "path/to/skywalking-nginx-lua/lib/skywalking/?. lua;;";

# Buffer represents the register inform and the queue of the finished segment

lua_shared_dict tracing_buffer 100m;

init_worker_by_lua_block {

local metadata_buffer = ngx.shared.tracing_buffer

metadata_buffer:set('serviceName', 'User Service Name')

-- Instance means the number of Nginx deloyment, does not mean the worker instances

metadata_buffer:set('serviceInstanceName', 'User Service Instance Name')

#Here you need to specify the backend address for reporting Skywalking. Port default is 12800

require("client"):startBackendTimer("http://127.0.0.1:12800")

}

server {

listen 8080;

location /test {

default_type text/html;

rewrite_by_lua_block {

require("tracer"):start("upstream service")

}

#Here is the address of the upstream service of nginx in the above picture

proxy_pass http://127.0.0.1:8080/upstream/test;

body_filter_by_lua_block {

if ngx.arg[2] then

require("tracer"):finish()

end

}

log_by_lua_block {

require("tracer"):prepareForReport()

}

}

}

}

Start OpenResty directly and specify the configuration file, for example: openrest-c /Users/tanjian/gitprojects/skywalking-nginx-lua/examples/nginx.conf"How to implement Skywalking to support HTTP 1.1 communication interface" is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report