In fact, the easiest way to install yaml filter plugin is to run:
sudo -u logstash ./bin/logstash-plugin install logstash-filter-yaml
But because of the network problem, I can’t connect to ruby-gems site, whether I use a proxy or not, the command always shows the warning below:

So I have to build the plugin by myself then install the plugin. If you meet with the same problem with me, you can following the instruction below.
Download the latest release from github: https://github.com/logstash-plugins/logstash-filter-yaml/releases

Copy the link of the zip file, download to your server and unzip to a folder. Let’s assume the folder is: /tmp/logstash-filter-yaml
Open the Gemfile of logstash: /usr/share/logstash/Gemfile
,and append the following to the last line:
gem "logstash-filter-yaml", "= 1.0.0", :path => "/tmp/logstash-filter-yaml-1.0.0"
Run the following command to compile the plugin:
sudo -u logstash bin/logstash-plugin prepare-offline-pack logstash-filter-yaml
After the compile process complete, run the following command:
sudo -u logstash bin/logstash-plugin install file:///usr/share/logstash/logstash-offline-plugins-6.8.1.zip