Logstash Issue: Got response code '401' contacting Elasticsearch at URL 'http://localhost:9200/'

while trying to run logstash 7.16.3 with this current version of Elasticsearch 8.1.0 .
I get the following error.

{:url=>"http://localhost:9200/", :exception=>LogStash::Outputs::ElasticSearch::HttpClient::Pool::BadResponseCodeError, :message=>"Got response code '401' contacting Elasticsearch at URL 'http://localhost:9200/'"}

Can you suggest a possible solution for this issue...?

You are not authorized. Ensure that your logstash output has proper credentials for your Elasticsearch instance.